diff --git a/.config/bash/module/Nix.sh b/.config/bash/module/Nix.sh index 9864dec..14b80fb 100644 --- a/.config/bash/module/Nix.sh +++ b/.config/bash/module/Nix.sh @@ -1,3 +1,5 @@ +export _nix_system_config="~/.config/linux/system" + # Rebuild system. # Optionally force the hostname. # Usage: nix_rebuild [HOSTNAME] @@ -5,9 +7,7 @@ function nix_rebuild() { local target="${1}" [[ "${target}" = "" ]] && target="${HOSTNAME}" - cd ${HOME}/.config/linux/system - nixos-rebuild boot --flake ".#${target}" - cd - + nixos-rebuild boot --flake "${_nix_system_config}#${target}" } # Rebuild and switch system. @@ -17,17 +17,13 @@ function nix_switch() { local target="${1}" [[ "${target}" = "" ]] && target="${HOSTNAME}" - cd "${HOME}/.config/linux/system" - nixos-rebuild switch --flake ".#${target}" - cd - + nixos-rebuild switch --flake "${_nix_system_config}#${target}" } # Update system versions. # Usage: nix_update function nix_update() { - cd "${HOME}/.config/linux/system" - nix flake update - cd - + nix flake update --flake "${_nix_system_config}" } # Free up root space. @@ -71,6 +67,11 @@ function nix_tmpshell() { } alias tmpshell="nix_tmpshell" +# Build live image. +function nix_live() { + nix build "${_nix_system_config}#installer.iso" +} + # Autocomplete with available hosts. function _comp_hosts() { local IFS=$'\n' diff --git a/.config/linux/system/flake.nix b/.config/linux/system/flake.nix index b893983..d4812d4 100644 --- a/.config/linux/system/flake.nix +++ b/.config/linux/system/flake.nix @@ -27,6 +27,12 @@ ./module/common/Users.nix ]; + # Live system. + installer = installer-gen.generate { + inputFlake = self; + targetConfig = nixosConfigurations.live; + }; + # Function to create a host. mkHost = { system, hostname, modules }: nixpkgs.lib.nixosSystem { inherit system; @@ -107,6 +113,14 @@ ]; }; + nixosConfigurations.live = self.mkHost { + hostname = "live"; + system = "x86_64-linux"; + modules = [ + ./module/Gnome.nix + ]; + }; + nixosConfigurations.work = self.mkHost { hostname = "work"; system = "x86_64-linux"; diff --git a/.config/linux/system/module/common/Nix.nix b/.config/linux/system/module/common/Nix.nix index cb8af05..b509f07 100644 --- a/.config/linux/system/module/common/Nix.nix +++ b/.config/linux/system/module/common/Nix.nix @@ -1,6 +1,4 @@ -{ ... }: - -{ +{ ... }: { nixpkgs.config.allowUnfree = true; nix.settings.auto-optimise-store = true; }