config-manager: Move installation of nh to module
And add `system` option that is required to pick the correct package from `nh`
This commit is contained in:
@@ -1,8 +1,12 @@
|
|||||||
# `config-manager`
|
# `config-manager`
|
||||||
`./config-manager` is a module that contains a script to make usage of this flake easier.
|
`./config-manager` is a module that contains a script to make usage of this flake easier.
|
||||||
|
|
||||||
To install it first add the module to the nixOS system connfiguration and then
|
To install it
|
||||||
run `nixos-rebuild switch --flake .#<configuration>`, after that `cm` will be available on `$PATH`.
|
1. first add the module to the nixOS system connfiguration
|
||||||
|
2. set `config-manager.flakePath = <path to this flake>`
|
||||||
|
3. set `config-manager.system = <system type for the machine>`
|
||||||
|
4. run `nixos-rebuild switch --flake .#<configuration>`
|
||||||
|
after that `cm` will be available on `$PATH`.
|
||||||
|
|
||||||
# Secrets
|
# Secrets
|
||||||
Secrets are managed by `agenix` (https://github.com/ryantm/agenix).
|
Secrets are managed by `agenix` (https://github.com/ryantm/agenix).
|
||||||
|
|||||||
@@ -1,11 +1,18 @@
|
|||||||
{ pkgs, lib, config, ... }:
|
{ inputs, pkgs, lib, config, ... }:
|
||||||
let
|
let
|
||||||
config-manager = let
|
flakePath = config.config-manager.flakePath;
|
||||||
flakePath = config.config-manager.flakePath;
|
nixosConfiguration = config.config-manager.nixosConfiguration;
|
||||||
nixosConfiguration = config.config-manager.nixosConfiguration;
|
system = config.config-manager.system;
|
||||||
in
|
|
||||||
|
nh = inputs.nh.packages."${system}".default;
|
||||||
|
|
||||||
|
config-manager =
|
||||||
if flakePath == "" then
|
if flakePath == "" then
|
||||||
throw "'config-manager.flakePath' cannot be empty"
|
throw "'config-manager.flakePath' cannot be empty"
|
||||||
|
else if nixosConfiguration == "" then
|
||||||
|
throw "'config-manager.nixosConfiguration' cannot be empty"
|
||||||
|
else if system == "" then
|
||||||
|
throw "'config-manager.system' cannot be empty"
|
||||||
else
|
else
|
||||||
pkgs.writeShellScriptBin "cm" ''
|
pkgs.writeShellScriptBin "cm" ''
|
||||||
help() {
|
help() {
|
||||||
@@ -25,7 +32,7 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch() {
|
switch() {
|
||||||
nh os switch --hostname ${nixosConfiguration} ${flakePath}
|
${nh}/bin/nh os switch --hostname ${nixosConfiguration} ${flakePath}
|
||||||
}
|
}
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
@@ -52,10 +59,19 @@ in
|
|||||||
default = config.networking.hostName;
|
default = config.networking.hostName;
|
||||||
description = "what nixosConfiguration to use";
|
description = "what nixosConfiguration to use";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
system = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "";
|
||||||
|
description = "what system the host is (x86_64-linux, aarch64-linux)";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
environment.systemPackages = [ config-manager ];
|
environment.systemPackages = [
|
||||||
|
nh
|
||||||
|
config-manager
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,7 @@
|
|||||||
|
|
||||||
sombrero = inputs.nixpkgs2211.lib.nixosSystem {
|
sombrero = inputs.nixpkgs2211.lib.nixosSystem {
|
||||||
system = "aarch64-linux";
|
system = "aarch64-linux";
|
||||||
|
specialArgs = { inherit inputs; };
|
||||||
modules = [
|
modules = [
|
||||||
./hosts/sombrero/configuration.nix
|
./hosts/sombrero/configuration.nix
|
||||||
inputs.home-manager.nixosModules.home-manager
|
inputs.home-manager.nixosModules.home-manager
|
||||||
|
|||||||
@@ -66,13 +66,15 @@
|
|||||||
|
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
inputs.agenix.packages."${system}".default
|
inputs.agenix.packages."${system}".default
|
||||||
inputs.nh.packages."${system}".default
|
|
||||||
coreutils
|
coreutils
|
||||||
gnumake
|
gnumake
|
||||||
bash
|
bash
|
||||||
];
|
];
|
||||||
|
|
||||||
config-manager.flakePath = "/home/alex/config";
|
config-manager = {
|
||||||
|
flakePath = "/home/alex/config";
|
||||||
|
system=system;
|
||||||
|
};
|
||||||
|
|
||||||
mod = {
|
mod = {
|
||||||
nix-index.enable = true;
|
nix-index.enable = true;
|
||||||
|
|||||||
@@ -370,7 +370,10 @@
|
|||||||
restic
|
restic
|
||||||
];
|
];
|
||||||
|
|
||||||
config-manager.flakePath = "/home/alex/config";
|
config-manager = {
|
||||||
|
flakePath = "/home/alex/config";
|
||||||
|
system = "aarch64-linux";
|
||||||
|
};
|
||||||
|
|
||||||
# Copy the NixOS configuration file and link it from the resulting system
|
# Copy the NixOS configuration file and link it from the resulting system
|
||||||
# (/run/current-system/configuration.nix). This is useful in case you
|
# (/run/current-system/configuration.nix). This is useful in case you
|
||||||
|
|||||||
Reference in New Issue
Block a user