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.
# 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'

View file

@ -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";

View file

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