From eb6ada8b323d41a3e37ba4ac6f0dde1d9a734df8 Mon Sep 17 00:00:00 2001 From: Dmitry Voronin Date: Tue, 20 Feb 2024 19:29:01 +0300 Subject: [PATCH] Nix : Add nix_live. --- .config/bash/module/Nix.sh | 19 ++++++++++--------- .config/linux/system/flake.nix | 14 ++++++++++++++ .config/linux/system/module/common/Nix.nix | 4 +--- 3 files changed, 25 insertions(+), 12 deletions(-) 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; }