Added copySysConf module.
This commit is contained in:
parent
9aced6065b
commit
82028fd0e1
3 changed files with 56 additions and 1 deletions
|
@ -3,7 +3,7 @@
|
|||
with lib;
|
||||
|
||||
let
|
||||
machinePath = (builtins.toPath ("/etc/nixos/machines/" + (fileContents /secret/hostName)));
|
||||
machinePath = (builtins.toPath ( ./machines + ("/" + (fileContents /secret/hostName))));
|
||||
machineConf = machinePath + "/configuration.nix";
|
||||
machineOpts = machinePath + "/options.nix";
|
||||
in {
|
||||
|
|
|
@ -5,6 +5,7 @@ with lib;
|
|||
{
|
||||
imports = [
|
||||
../../options/machine.nix
|
||||
../../options/copySysConf.nix
|
||||
];
|
||||
|
||||
config.machine = {
|
||||
|
@ -43,4 +44,9 @@ with lib;
|
|||
allowedTCPPortRanges = [ { from = 1714; to = 1764; } ];
|
||||
};
|
||||
};
|
||||
|
||||
config.system.copySysConf = {
|
||||
enable = true;
|
||||
addToNixPath = false;
|
||||
};
|
||||
}
|
||||
|
|
49
options/copySysConf.nix
Normal file
49
options/copySysConf.nix
Normal file
|
@ -0,0 +1,49 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.system.copySysConf;
|
||||
copySysConf = pkgs.stdenv.mkDerivation rec {
|
||||
srcPath = ../.;
|
||||
name = "NixOS_Configuration-${version}";
|
||||
version = "0.1";
|
||||
# this does not work yet for some reason
|
||||
# version = commitIdFromGitRepo "${srcPath}/.git";
|
||||
|
||||
src = cleanSource srcPath;
|
||||
|
||||
installPhase = ''
|
||||
cp -R ./. $out
|
||||
'';
|
||||
};
|
||||
|
||||
in {
|
||||
options.system.copySysConf = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
description = ''
|
||||
Wether to copy the systems configuration.
|
||||
'';
|
||||
};
|
||||
addToNixPath = mkOption {
|
||||
type = types.bool;
|
||||
description = ''
|
||||
Use backup for nixos-rebuild.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
# probably don't need to add it to systemPackages
|
||||
environment.systemPackages = [ copySysConf ];
|
||||
nix = mkIf cfg.addToNixPath {
|
||||
# Do not use lib.optionals as it would override the default nixPath
|
||||
nixPath = [
|
||||
"nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos"
|
||||
"nixos-config=${copySysConf}/configuration.nix"
|
||||
"/nix/var/nix/profiles/per-user/root/channels"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue