environment.etc: Add convenience option 'text'
This allows writing environment.etc.hosts.text = "127.0.0.1 localhost"; instead of environment.etc.hosts.source = pkgs.writeText "hosts" "127.0.0.1 localhost";
This commit is contained in:
parent
ab238804b8
commit
1daab1ebf5
@ -48,7 +48,7 @@ in
|
|||||||
"rpc".source = pkgs.glibc + "/etc/rpc";
|
"rpc".source = pkgs.glibc + "/etc/rpc";
|
||||||
|
|
||||||
# /etc/hosts: Hostname-to-IP mappings.
|
# /etc/hosts: Hostname-to-IP mappings.
|
||||||
"hosts".source = pkgs.writeText "hosts"
|
"hosts".text =
|
||||||
''
|
''
|
||||||
127.0.0.1 localhost
|
127.0.0.1 localhost
|
||||||
${optionalString cfg.enableIPv6 ''
|
${optionalString cfg.enableIPv6 ''
|
||||||
@ -58,7 +58,7 @@ in
|
|||||||
'';
|
'';
|
||||||
|
|
||||||
# /etc/resolvconf.conf: Configuration for openresolv.
|
# /etc/resolvconf.conf: Configuration for openresolv.
|
||||||
"resolvconf.conf".source = pkgs.writeText "resolvconf.conf" (
|
"resolvconf.conf".text =
|
||||||
''
|
''
|
||||||
# This is the default, but we must set it here to prevent
|
# This is the default, but we must set it here to prevent
|
||||||
# a collision with an apparently unrelated environment
|
# a collision with an apparently unrelated environment
|
||||||
@ -74,7 +74,7 @@ in
|
|||||||
'' + optionalString config.services.bind.enable ''
|
'' + optionalString config.services.bind.enable ''
|
||||||
# This hosts runs a full-blown DNS resolver.
|
# This hosts runs a full-blown DNS resolver.
|
||||||
name_servers='127.0.0.1'
|
name_servers='127.0.0.1'
|
||||||
'' );
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
# The ‘ip-up’ target is started when we have IP connectivity. So
|
# The ‘ip-up’ target is started when we have IP connectivity. So
|
||||||
|
@ -45,9 +45,6 @@ in
|
|||||||
|
|
||||||
options = singleton ({ name, config, ... }:
|
options = singleton ({ name, config, ... }:
|
||||||
{ options = {
|
{ options = {
|
||||||
source = mkOption {
|
|
||||||
description = "Path of the source file.";
|
|
||||||
};
|
|
||||||
|
|
||||||
target = mkOption {
|
target = mkOption {
|
||||||
description = ''
|
description = ''
|
||||||
@ -57,6 +54,17 @@ in
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
text = mkOption {
|
||||||
|
default = null;
|
||||||
|
type = types.nullOr types.string;
|
||||||
|
description = "Text of the file.";
|
||||||
|
};
|
||||||
|
|
||||||
|
source = mkOption {
|
||||||
|
types = types.path;
|
||||||
|
description = "Path of the source file.";
|
||||||
|
};
|
||||||
|
|
||||||
mode = mkOption {
|
mode = mkOption {
|
||||||
default = "symlink";
|
default = "symlink";
|
||||||
example = "0600";
|
example = "0600";
|
||||||
@ -71,6 +79,8 @@ in
|
|||||||
|
|
||||||
config = {
|
config = {
|
||||||
target = mkDefault name;
|
target = mkDefault name;
|
||||||
|
source = mkIf (config.text != null)
|
||||||
|
(mkDefault (pkgs.writeText "etc-file" config.text));
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -7,28 +7,6 @@ let
|
|||||||
|
|
||||||
fileSystems = attrValues config.fileSystems;
|
fileSystems = attrValues config.fileSystems;
|
||||||
|
|
||||||
fstab = pkgs.writeText "fstab"
|
|
||||||
''
|
|
||||||
# This is a generated file. Do not edit!
|
|
||||||
|
|
||||||
# Filesystems.
|
|
||||||
${flip concatMapStrings fileSystems (fs:
|
|
||||||
(if fs.device != null then fs.device else "/dev/disk/by-label/${fs.label}")
|
|
||||||
+ " " + fs.mountPoint
|
|
||||||
+ " " + fs.fsType
|
|
||||||
+ " " + fs.options
|
|
||||||
+ " 0"
|
|
||||||
+ " " + (if fs.fsType == "none" || fs.device == "none" || fs.fsType == "btrfs" || fs.fsType == "tmpfs" || fs.noCheck then "0" else
|
|
||||||
if fs.mountPoint == "/" then "1" else "2")
|
|
||||||
+ "\n"
|
|
||||||
)}
|
|
||||||
|
|
||||||
# Swap devices.
|
|
||||||
${flip concatMapStrings config.swapDevices (sw:
|
|
||||||
"${sw.device} none swap\n"
|
|
||||||
)}
|
|
||||||
'';
|
|
||||||
|
|
||||||
fileSystemOpts = { name, ... }: {
|
fileSystemOpts = { name, ... }: {
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
@ -171,10 +149,27 @@ in
|
|||||||
[ pkgs.ntfs3g pkgs.cifs_utils ]
|
[ pkgs.ntfs3g pkgs.cifs_utils ]
|
||||||
++ config.system.fsPackages;
|
++ config.system.fsPackages;
|
||||||
|
|
||||||
environment.etc = singleton
|
environment.etc.fstab.text =
|
||||||
{ source = fstab;
|
''
|
||||||
target = "fstab";
|
# This is a generated file. Do not edit!
|
||||||
};
|
|
||||||
|
# Filesystems.
|
||||||
|
${flip concatMapStrings fileSystems (fs:
|
||||||
|
(if fs.device != null then fs.device else "/dev/disk/by-label/${fs.label}")
|
||||||
|
+ " " + fs.mountPoint
|
||||||
|
+ " " + fs.fsType
|
||||||
|
+ " " + fs.options
|
||||||
|
+ " 0"
|
||||||
|
+ " " + (if fs.fsType == "none" || fs.device == "none" || fs.fsType == "btrfs" || fs.fsType == "tmpfs" || fs.noCheck then "0" else
|
||||||
|
if fs.mountPoint == "/" then "1" else "2")
|
||||||
|
+ "\n"
|
||||||
|
)}
|
||||||
|
|
||||||
|
# Swap devices.
|
||||||
|
${flip concatMapStrings config.swapDevices (sw:
|
||||||
|
"${sw.device} none swap\n"
|
||||||
|
)}
|
||||||
|
'';
|
||||||
|
|
||||||
# Provide a target that pulls in all filesystems.
|
# Provide a target that pulls in all filesystems.
|
||||||
systemd.targets.fs =
|
systemd.targets.fs =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user