diff --git a/common/global/tailscale.nix b/common/global/tailscale.nix index 9eb0793..3bd6eed 100644 --- a/common/global/tailscale.nix +++ b/common/global/tailscale.nix @@ -1,12 +1,21 @@ -{ config, pkgs, ... }: +{ config, pkgs, lib, ... }: +with lib; let + cfg = config.custom.tailscale; in { imports = [ ./tailscale_lib.nix ]; - services.tailscaleAutoconnect.enable = true; + options.custom.tailscale = { + enable = mkEnableOption { + description = "Enable Tailscale"; + default = true; + }; + }; - services.tailscale.package = pkgs.unstable.tailscale; - - environment.persistence."/persist".directories = [ "/var/lib/tailscale" ]; + config = mkIf cfg.enable { + services.tailscaleAutoconnect.enable = true; + services.tailscale.package = pkgs.unstable.tailscale; + environment.persistence."/persist".directories = [ "/var/lib/tailscale" ]; + }; } diff --git a/common/impermanence.nix b/common/impermanence.nix index 607cc40..eb043ee 100644 --- a/common/impermanence.nix +++ b/common/impermanence.nix @@ -1,7 +1,5 @@ { pkgs, inputs, ... }: { - imports = [ inputs.impermanence.nixosModules.impermanence ]; - environment.persistence = { "/persist" = { directories = [ "/var/lib/nixos" ]; diff --git a/common/lxc-node.nix b/common/lxc-node.nix new file mode 100644 index 0000000..46a110b --- /dev/null +++ b/common/lxc-node.nix @@ -0,0 +1,7 @@ +{ + imports = [ + ]; + + custom.tailscale.enable = false; + proxmoxLXC.manageNetwork = true; +} diff --git a/flake.lock b/flake.lock index 20b84ee..60420cf 100644 --- a/flake.lock +++ b/flake.lock @@ -261,6 +261,42 @@ "type": "github" } }, + "nixlib": { + "locked": { + "lastModified": 1726966855, + "narHash": "sha256-25ByioeOBFcnitO5lM/Mufnv/u7YtHEHEM8QFuiS40k=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "575704ff85d3a41dc5bfef7b55380cbc7b87f3c2", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixos-generators": { + "inputs": { + "nixlib": "nixlib", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1727053438, + "narHash": "sha256-t/+z1Tf7hSaStU1pBYkY7i0/GkG+YIPSmfeRrK8eYUw=", + "owner": "nix-community", + "repo": "nixos-generators", + "rev": "e8c1cd886cc17e31e424f915efd32e84d8af0ce9", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixos-generators", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1726320982, @@ -352,6 +388,7 @@ "home-manager": "home-manager", "impermanence": "impermanence", "nix-index-database": "nix-index-database", + "nixos-generators": "nixos-generators", "nixpkgs": "nixpkgs", "nixpkgs-unstable": "nixpkgs-unstable", "nixvim": "nixvim", diff --git a/flake.nix b/flake.nix index 6b9eb26..98d3f3e 100644 --- a/flake.nix +++ b/flake.nix @@ -17,6 +17,10 @@ url = "github:nix-community/nix-index-database"; inputs.nixpkgs.follows = "nixpkgs"; }; + nixos-generators = { + url = "github:nix-community/nixos-generators"; + inputs.nixpkgs.follows = "nixpkgs"; + }; nixvim = { url = "github:nix-community/nixvim"; inputs.nixpkgs.follows = "nixpkgs-unstable"; @@ -38,6 +42,8 @@ disko, home-manager, sops-nix, + nixos-generators, + impermanence, ... }@inputs: let @@ -59,6 +65,7 @@ ) disko.nixosModules.disko sops-nix.nixosModules.sops + impermanence.nixosModules.impermanence home-manager.nixosModules.home-manager { home-manager = { @@ -166,6 +173,21 @@ }; }; + packages.x86_64-linux = { + kopia-lxc = nixos-generators.nixosGenerate { + system = "x86_64-linux"; + format = "proxmox-lxc"; + modules = [ + sops-nix.nixosModules.sops + impermanence.nixosModules.impermanence + ./hosts/kopia-lxc + ]; + specialArgs = { + inherit inputs self; + }; + }; + }; + checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib; formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-rfc-style; diff --git a/hosts/kopia-lxc/default.nix b/hosts/kopia-lxc/default.nix new file mode 100644 index 0000000..7b00dfc --- /dev/null +++ b/hosts/kopia-lxc/default.nix @@ -0,0 +1,7 @@ +{ + imports = [ + ../../common/global + ../../common/lxc-node.nix + ]; + networking.hostName = "kopia"; +}