Nix : Add nix_live.

This commit is contained in:
Dmitry Voronin 2024-02-20 19:29:01 +03:00
parent f41c9a3f01
commit eb6ada8b32
3 changed files with 25 additions and 12 deletions

View file

@ -1,3 +1,5 @@
export _nix_system_config="~/.config/linux/system"
# Rebuild system. # Rebuild system.
# Optionally force the hostname. # Optionally force the hostname.
# Usage: nix_rebuild [HOSTNAME] # Usage: nix_rebuild [HOSTNAME]
@ -5,9 +7,7 @@ function nix_rebuild() {
local target="${1}" local target="${1}"
[[ "${target}" = "" ]] && target="${HOSTNAME}" [[ "${target}" = "" ]] && target="${HOSTNAME}"
cd ${HOME}/.config/linux/system nixos-rebuild boot --flake "${_nix_system_config}#${target}"
nixos-rebuild boot --flake ".#${target}"
cd -
} }
# Rebuild and switch system. # Rebuild and switch system.
@ -17,17 +17,13 @@ function nix_switch() {
local target="${1}" local target="${1}"
[[ "${target}" = "" ]] && target="${HOSTNAME}" [[ "${target}" = "" ]] && target="${HOSTNAME}"
cd "${HOME}/.config/linux/system" nixos-rebuild switch --flake "${_nix_system_config}#${target}"
nixos-rebuild switch --flake ".#${target}"
cd -
} }
# Update system versions. # Update system versions.
# Usage: nix_update # Usage: nix_update
function nix_update() { function nix_update() {
cd "${HOME}/.config/linux/system" nix flake update --flake "${_nix_system_config}"
nix flake update
cd -
} }
# Free up root space. # Free up root space.
@ -71,6 +67,11 @@ function nix_tmpshell() {
} }
alias tmpshell="nix_tmpshell" alias tmpshell="nix_tmpshell"
# Build live image.
function nix_live() {
nix build "${_nix_system_config}#installer.iso"
}
# Autocomplete with available hosts. # Autocomplete with available hosts.
function _comp_hosts() { function _comp_hosts() {
local IFS=$'\n' local IFS=$'\n'

View file

@ -27,6 +27,12 @@
./module/common/Users.nix ./module/common/Users.nix
]; ];
# Live system.
installer = installer-gen.generate {
inputFlake = self;
targetConfig = nixosConfigurations.live;
};
# Function to create a host. # Function to create a host.
mkHost = { system, hostname, modules }: nixpkgs.lib.nixosSystem { mkHost = { system, hostname, modules }: nixpkgs.lib.nixosSystem {
inherit system; inherit system;
@ -107,6 +113,14 @@
]; ];
}; };
nixosConfigurations.live = self.mkHost {
hostname = "live";
system = "x86_64-linux";
modules = [
./module/Gnome.nix
];
};
nixosConfigurations.work = self.mkHost { nixosConfigurations.work = self.mkHost {
hostname = "work"; hostname = "work";
system = "x86_64-linux"; system = "x86_64-linux";

View file

@ -1,6 +1,4 @@
{ ... }: { ... }: {
{
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
nix.settings.auto-optimise-store = true; nix.settings.auto-optimise-store = true;
} }