Implement files under /etc
This commit is contained in:
parent
8b3bba30af
commit
b3c7f71456
10 changed files with 494 additions and 242 deletions
|
|
@ -1,5 +1,6 @@
|
|||
{ lib
|
||||
, pkgs
|
||||
, config
|
||||
, ...
|
||||
}:
|
||||
let
|
||||
|
|
@ -30,16 +31,42 @@ let
|
|||
'';
|
||||
})
|
||||
);
|
||||
in
|
||||
{
|
||||
options = {
|
||||
system-manager.services = lib.mkOption {
|
||||
type = with lib.types; listOf str;
|
||||
|
||||
etcFiles = {
|
||||
foo = {
|
||||
text = ''
|
||||
This is just a test!
|
||||
'';
|
||||
target = "foo_test";
|
||||
};
|
||||
|
||||
"baz/bar/foo2" = {
|
||||
text = ''
|
||||
Another test!
|
||||
'';
|
||||
mode = "symlink";
|
||||
};
|
||||
|
||||
foo3 = {
|
||||
text = "boo!";
|
||||
mode = "0700";
|
||||
user = "root";
|
||||
group = "root";
|
||||
};
|
||||
|
||||
out-of-store = {
|
||||
source = "/run/systemd/system/";
|
||||
};
|
||||
};
|
||||
|
||||
in
|
||||
{
|
||||
config = {
|
||||
system-manager.services = lib.attrNames services;
|
||||
system.stateVersion = lib.trivial.release;
|
||||
system-manager = {
|
||||
etcFiles = lib.attrNames etcFiles;
|
||||
services = lib.attrNames services;
|
||||
};
|
||||
environment.etc = etcFiles;
|
||||
systemd = { inherit services; };
|
||||
};
|
||||
}
|
||||
|
|
|
|||
34
nix/modules/system-manager.nix
Normal file
34
nix/modules/system-manager.nix
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
{ lib
|
||||
, pkgs
|
||||
, config
|
||||
, ...
|
||||
}:
|
||||
{
|
||||
options.system-manager = {
|
||||
services = lib.mkOption {
|
||||
type = with lib.types; listOf str;
|
||||
};
|
||||
|
||||
etcFiles = lib.mkOption {
|
||||
type = with lib.types; listOf str;
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
# Avoid some standard NixOS assertions
|
||||
boot = {
|
||||
loader.grub.enable = false;
|
||||
initrd.enable = false;
|
||||
};
|
||||
|
||||
assertions = lib.flip map config.system-manager.etcFiles (entry:
|
||||
{
|
||||
assertion = lib.hasAttr entry config.environment.etc;
|
||||
message = lib.concatStringsSep " " [
|
||||
"The entry ${entry} that was passed to system-manager.etcFiles"
|
||||
"is not present in environment.etc"
|
||||
];
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue