From a1d4a866a232ff3dcc8431f255cf009198420ed5 Mon Sep 17 00:00:00 2001 From: Erwin Boskma Date: Mon, 24 Jan 2022 11:17:44 +0100 Subject: [PATCH] Added container generator config --- flake.lock | 156 +++++++++++++++--------------------- flake.nix | 59 +++++++++++++- modules/desktop/default.nix | 6 +- 3 files changed, 125 insertions(+), 96 deletions(-) diff --git a/flake.lock b/flake.lock index 4edbbda..3ff0b68 100644 --- a/flake.lock +++ b/flake.lock @@ -15,28 +15,17 @@ "type": "github" } }, - "flake-utils_2": { - "locked": { - "lastModified": 1638122382, - "narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "74f7e4319258e287b0f9cb95426c9853b282730b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "ha-now-playing": { "inputs": { - "naersk": "naersk", + "naersk": [ + "naersk" + ], "nixpkgs": [ "nixpkgs" ], - "rust-overlay": "rust-overlay", + "rust-overlay": [ + "rust-overlay" + ], "utils": [ "flake-utils" ] @@ -63,11 +52,11 @@ ] }, "locked": { - "lastModified": 1642117744, - "narHash": "sha256-/SvxBe/m6JiRSlKIrgD6LQxee9GGewFyq+lsPxoViMY=", + "lastModified": 1642463065, + "narHash": "sha256-Db53xzDOouhsDAQ/QCvLeM0r7p+my5Zb5jgWGpCrOVo=", "owner": "nix-community", "repo": "home-manager", - "rev": "a5dd5d5f197724f3065fd39c59c7ccea3c8dcb8f", + "rev": "c491331718bd41722a2982a5532eb0ff51c3ca28", "type": "github" }, "original": { @@ -78,78 +67,67 @@ }, "naersk": { "inputs": { - "nixpkgs": "nixpkgs" + "nixpkgs": [ + "nixpkgs" + ] }, "locked": { - "lastModified": 1637576998, - "narHash": "sha256-bGQ66hh4Dl78T9bd1pqdp6fprHMCkrkeKqED6sDUYqo=", - "owner": "nmattia", + "lastModified": 1639947939, + "narHash": "sha256-pGsM8haJadVP80GFq4xhnSpNitYNQpaXk4cnA796Cso=", + "owner": "nix-community", "repo": "naersk", - "rev": "b043f2447a4a761529254f4983cacd94b034a122", + "rev": "2fc8ce9d3c025d59fee349c1f80be9785049d653", "type": "github" }, "original": { - "owner": "nmattia", - "ref": "master", + "owner": "nix-community", "repo": "naersk", "type": "github" } }, - "naersk_2": { - "inputs": { - "nixpkgs": "nixpkgs_4" - }, + "nixlib": { "locked": { - "lastModified": 1637576998, - "narHash": "sha256-bGQ66hh4Dl78T9bd1pqdp6fprHMCkrkeKqED6sDUYqo=", - "owner": "nmattia", - "repo": "naersk", - "rev": "b043f2447a4a761529254f4983cacd94b034a122", + "lastModified": 1636849918, + "narHash": "sha256-nzUK6dPcTmNVrgTAC1EOybSMsrcx+QrVPyqRdyKLkjA=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "28a5b0557f14124608db68d3ee1f77e9329e9dd5", "type": "github" }, "original": { - "owner": "nmattia", - "ref": "master", - "repo": "naersk", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixos-generators": { + "inputs": { + "nixlib": "nixlib", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1640542138, + "narHash": "sha256-2f+Dslfzkuj0pgBl+70lkiTCg+U2Q0TcOikwxpsU+Fk=", + "owner": "nix-community", + "repo": "nixos-generators", + "rev": "296067b9c7a172d294831dec89d86847f30a7cfc", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixos-generators", "type": "github" } }, "nixpkgs": { "locked": { - "lastModified": 1641887635, - "narHash": "sha256-kDGpufwzVaiGe5e1sBUBPo9f1YN+nYHJlYqCaVpZTQQ=", - "path": "/nix/store/1hdyp90ilq8gksc56dryg991kq3pc9bb-source", - "rev": "b2737d4980a17cc2b7d600d7d0b32fd7333aca88", - "type": "path" - }, - "original": { - "id": "nixpkgs", - "type": "indirect" - } - }, - "nixpkgs_2": { - "locked": { - "lastModified": 1642069818, - "narHash": "sha256-666w6j8wl/bojfgpp0k58/UJ5rbrdYFbI2RFT2BXbSQ=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "46821ea01c8f54d2a20f5a503809abfc605269d7", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_3": { - "locked": { - "lastModified": 1642104392, - "narHash": "sha256-m71b7MgMh9FDv4MnI5sg9MiBVW6DhE1zq+d/KlLWSC8=", + "lastModified": 1642281915, + "narHash": "sha256-jcMsXmmO1knyf99o242A+2cy1A0eKa9afly0cwBknPA=", "owner": "nixos", "repo": "nixpkgs", - "rev": "5aaed40d22f0d9376330b6fa413223435ad6fee5", + "rev": "d5dae6569ea9952f1ae4e727946d93a71c507821", "type": "github" }, "original": { @@ -159,22 +137,11 @@ "type": "github" } }, - "nixpkgs_4": { - "locked": { - "lastModified": 1641887635, - "narHash": "sha256-kDGpufwzVaiGe5e1sBUBPo9f1YN+nYHJlYqCaVpZTQQ=", - "path": "/nix/store/1hdyp90ilq8gksc56dryg991kq3pc9bb-source", - "rev": "b2737d4980a17cc2b7d600d7d0b32fd7333aca88", - "type": "path" - }, - "original": { - "id": "nixpkgs", - "type": "indirect" - } - }, "pamedia": { "inputs": { - "naersk": "naersk_2", + "naersk": [ + "naersk" + ], "nixpkgs": [ "nixpkgs" ], @@ -202,22 +169,29 @@ "flake-utils": "flake-utils", "ha-now-playing": "ha-now-playing", "home-manager": "home-manager", - "nixpkgs": "nixpkgs_3", + "naersk": "naersk", + "nixos-generators": "nixos-generators", + "nixpkgs": "nixpkgs", "pamedia": "pamedia", + "rust-overlay": "rust-overlay", "sops": "sops" } }, "rust-overlay": { "inputs": { - "flake-utils": "flake-utils_2", - "nixpkgs": "nixpkgs_2" + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] }, "locked": { - "lastModified": 1642128126, - "narHash": "sha256-av8JUACdrTfQYl/ftZJvKpZEmZfa0avCq7tt5Usdoq0=", + "lastModified": 1642559502, + "narHash": "sha256-Dy3ziFejnG1jSsMem19nxDySzGCWbWujUDRQFIDT7BE=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "ce4ef6f2d74f2b68f7547df1de22d1b0037ce4ad", + "rev": "308ac16f932e52394ca3d35dbd6cda1940aaa0f5", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 71501f8..65f87d4 100644 --- a/flake.nix +++ b/flake.nix @@ -11,6 +11,22 @@ flake-utils.url = "github:numtide/flake-utils"; + nixos-generators = { + url = "github:nix-community/nixos-generators"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + naersk = { + url = "github:nix-community/naersk"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.flake-utils.follows = "flake-utils"; + }; + sops = { url = "github:Mic92/sops-nix"; inputs.nixpkgs.follows = "nixpkgs"; @@ -20,12 +36,15 @@ url = "git+https://@git.datarift.nl/erwin/ha-now-playing.git?ref=main"; inputs.nixpkgs.follows = "nixpkgs"; inputs.utils.follows = "flake-utils"; + inputs.naersk.follows = "naersk"; + inputs.rust-overlay.follows = "rust-overlay"; }; pamedia = { url = "git+https://git.datarift.nl/erwin/pamedia-rs.git?ref=main"; inputs.nixpkgs.follows = "nixpkgs"; inputs.utils.follows = "flake-utils"; + inputs.naersk.follows = "naersk"; }; }; @@ -39,8 +58,36 @@ modules = [ { _module.args.inputs = inputs; } { _module.args.self-overlay = self.overlay; } - { _module.args.pamedia-overlay = pamedia.overlays.${system}; } - { _module.args.ha-now-playing-overlay = ha-now-playing.overlays.${system}; } + ({ ... }: { + imports = builtins.attrValues self.nixosModules ++ [ + { + nix.nixPath = [ "nixpkgs=${nixpkgs}" ]; + nixpkgs.overlays = [ + self.overlay + ha-now-playing.overlays.${system} + pamedia.overlays.${system} + ]; + } + + baseConfig + home-manager.nixosModules.home-manager + { home-manager.useUserPackages = true; } + ]; + + system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev; + nix.registry.nixpkgs.flake = nixpkgs; + }) + sops.nixosModules.sops + ]; + }; + + defContainer = system: baseConfig: + nixos-generators.nixosGenerate { + pkgs = nixpkgs.legacyPackages.${system}; + format = "lxc"; + modules = [ + { _module.args.inputs = inputs; } + { _module.args.self-overlay = self.overlay; } ({ ... }: { imports = builtins.attrValues self.nixosModules ++ [ { @@ -105,6 +152,14 @@ ]; }; }; + + nixosContainers = { + proxy = defContainer "x86_64-linux" { + imports = [ + (import (./machines/proxy/configuration.nix) { inherit self; }) + ]; + }; + }; } // (flake-utils.lib.eachSystem [ "aarch64-linux" "x86_64-linux" ]) (system: diff --git a/modules/desktop/default.nix b/modules/desktop/default.nix index 4e6f4fb..32b178c 100644 --- a/modules/desktop/default.nix +++ b/modules/desktop/default.nix @@ -1,4 +1,4 @@ -{ lib, pkgs, config, inputs, self-overlay, ha-now-playing-overlay, pamedia-overlay, ... }: +{ lib, pkgs, config, inputs, self-overlay, ... }: with lib; let cfg = config.eboskma.desktop; @@ -161,8 +161,8 @@ in { nixpkgs.overlays = [ self-overlay - ha-now-playing-overlay - pamedia-overlay + inputs.ha-now-playing.overlays.${pkgs.system} + inputs.pamedia.overlays.${pkgs.system} ]; } ../../home-manager/modules/alacritty