nixos/{containers,cri-o,podman}: move copyFile to nixos/lib/utils
This commit is contained in:
parent
f569e1f399
commit
008de9ca3c
4 changed files with 13 additions and 21 deletions
|
@ -2,6 +2,11 @@ pkgs: with pkgs.lib;
|
|||
|
||||
rec {
|
||||
|
||||
# Copy configuration files to avoid having the entire sources in the system closure
|
||||
copyFile = filePath: pkgs.runCommandNoCC (builtins.unsafeDiscardStringContext (builtins.baseNameOf filePath)) {} ''
|
||||
cp ${filePath} $out
|
||||
'';
|
||||
|
||||
# Check whenever fileSystem is needed for boot. NOTE: Make sure
|
||||
# pathsNeededForBoot is closed under the parent relationship, i.e. if /a/b/c
|
||||
# is in the list, put /a and /a/b in as well.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{ config, lib, pkgs, utils, ... }:
|
||||
let
|
||||
cfg = config.virtualisation.containers;
|
||||
|
||||
|
@ -13,10 +13,6 @@ let
|
|||
json2toml "$valuePath" "$out"
|
||||
'';
|
||||
|
||||
# Copy configuration files to avoid having the entire sources in the system closure
|
||||
copyFile = filePath: pkgs.runCommandNoCC (builtins.unsafeDiscardStringContext (builtins.baseNameOf filePath)) {} ''
|
||||
cp ${filePath} $out
|
||||
'';
|
||||
in
|
||||
{
|
||||
meta = {
|
||||
|
@ -136,7 +132,7 @@ in
|
|||
|
||||
environment.etc."containers/policy.json".source =
|
||||
if cfg.policy != {} then pkgs.writeText "policy.json" (builtins.toJSON cfg.policy)
|
||||
else copyFile "${pkgs.skopeo.src}/default-policy.json";
|
||||
else utils.copyFile "${pkgs.skopeo.src}/default-policy.json";
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{ config, lib, pkgs, utils, ... }:
|
||||
|
||||
with lib;
|
||||
let
|
||||
|
@ -6,10 +6,6 @@ let
|
|||
|
||||
crioPackage = (pkgs.cri-o.override { inherit (cfg) extraPackages; });
|
||||
|
||||
# Copy configuration files to avoid having the entire sources in the system closure
|
||||
copyFile = filePath: pkgs.runCommandNoCC (builtins.unsafeDiscardStringContext (builtins.baseNameOf filePath)) { } ''
|
||||
cp ${filePath} $out
|
||||
'';
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
|
@ -89,7 +85,7 @@ in
|
|||
config = mkIf cfg.enable {
|
||||
environment.systemPackages = [ cfg.package pkgs.cri-tools ];
|
||||
|
||||
environment.etc."crictl.yaml".source = copyFile "${pkgs.cri-o-unwrapped.src}/crictl.yaml";
|
||||
environment.etc."crictl.yaml".source = utils.copyFile "${pkgs.cri-o-unwrapped.src}/crictl.yaml";
|
||||
|
||||
environment.etc."crio/crio.conf.d/00-default.conf".text = ''
|
||||
[crio]
|
||||
|
@ -116,8 +112,8 @@ in
|
|||
''}
|
||||
'';
|
||||
|
||||
environment.etc."cni/net.d/10-crio-bridge.conf".source = copyFile "${pkgs.cri-o-unwrapped.src}/contrib/cni/10-crio-bridge.conf";
|
||||
environment.etc."cni/net.d/99-loopback.conf".source = copyFile "${pkgs.cri-o-unwrapped.src}/contrib/cni/99-loopback.conf";
|
||||
environment.etc."cni/net.d/10-crio-bridge.conf".source = utils.copyFile "${pkgs.cri-o-unwrapped.src}/contrib/cni/10-crio-bridge.conf";
|
||||
environment.etc."cni/net.d/99-loopback.conf".source = utils.copyFile "${pkgs.cri-o-unwrapped.src}/contrib/cni/99-loopback.conf";
|
||||
|
||||
# Enable common /etc/containers configuration
|
||||
virtualisation.containers.enable = true;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{ config, lib, pkgs, utils, ... }:
|
||||
let
|
||||
cfg = config.virtualisation.podman;
|
||||
|
||||
|
@ -21,11 +21,6 @@ let
|
|||
done
|
||||
'';
|
||||
|
||||
# Copy configuration files to avoid having the entire sources in the system closure
|
||||
copyFile = filePath: pkgs.runCommandNoCC (builtins.unsafeDiscardStringContext (builtins.baseNameOf filePath)) {} ''
|
||||
cp ${filePath} $out
|
||||
'';
|
||||
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
|
@ -88,7 +83,7 @@ in
|
|||
environment.systemPackages = [ cfg.package ]
|
||||
++ lib.optional cfg.dockerCompat dockerCompat;
|
||||
|
||||
environment.etc."cni/net.d/87-podman-bridge.conflist".source = copyFile "${pkgs.podman-unwrapped.src}/cni/87-podman-bridge.conflist";
|
||||
environment.etc."cni/net.d/87-podman-bridge.conflist".source = utils.copyFile "${pkgs.podman-unwrapped.src}/cni/87-podman-bridge.conflist";
|
||||
|
||||
# Enable common /etc/containers configuration
|
||||
virtualisation.containers.enable = true;
|
||||
|
|
Loading…
Reference in a new issue