From 99a388b850a54665b417ba2a4613dd80be0775ea Mon Sep 17 00:00:00 2001 From: albert Date: Wed, 20 Mar 2024 17:23:30 +0900 Subject: [PATCH] Update --- lib/default.nix | 34 ++++++++++++++++++++- nixos/containers/rdesktop.nix | 30 ------------------ nixos/containers/rdesktop/default.nix | 18 +++++++++++ nixos/hosts/framework-server/containers.nix | 8 +++++ nixos/hosts/framework-server/default.nix | 12 ++++---- 5 files changed, 65 insertions(+), 37 deletions(-) delete mode 100644 nixos/containers/rdesktop.nix create mode 100644 nixos/containers/rdesktop/default.nix create mode 100644 nixos/hosts/framework-server/containers.nix diff --git a/lib/default.nix b/lib/default.nix index acba3ee1..27747578 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -30,6 +30,38 @@ modules = [ ../home-manager/${type}.nix ]; }; + # Helper function for generating container configs + mkContainer = { + container, + username ? "albert", + desktop ? null, + gpu ? null, + system ? "x86_64-linux", + theme ? "stylix", + type ? "default", + repo ? "nixpkgs", + unfree ? false + }: { + autoStart = true; + privateNetwork = false; + specialArgs = { inherit desktop container username stateVersion gpu system theme; }; + config = { lib, container, username, desktop, gpu, system, theme, type, repo, unfree, pkgs, stateVersion}: { + # Choose whether to pull from stable or unstable + pkgs = import inputs.${repo} { + inherit system; + config.allowUnfree = unfree; + hostPlatform = system; + }; + # Some packages (ie, Vintage Story) I want to keep on unstable no matter what default repo I use + pkgs-unstable = import inputs.nixpkgs-unstable { + inherit system; + config.allowUnfree = unfree; + hostPlatform = system; + }; + imports = [ ../nixos/containers/rdesktop ]; + }; + }; + # Helper function for generating host configs mkHost = { hostname, @@ -42,7 +74,7 @@ repo ? "nixpkgs", unfree ? false }:inputs.${repo}.lib.nixosSystem { - specialArgs = { inherit inputs outputs desktop hostname username stateVersion gpu system theme; + specialArgs = { inherit inputs outputs desktop hostname username hmStateVersion stateVersion gpu system theme self; # Choose whether to pull from stable or unstable pkgs = import inputs.${repo} { inherit system; diff --git a/nixos/containers/rdesktop.nix b/nixos/containers/rdesktop.nix deleted file mode 100644 index 9bde282e..00000000 --- a/nixos/containers/rdesktop.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ username, stateVersion, desktop, ... }: { - networking.firewall.allowedTCPPorts = [ 3390 ]; - - containers.rdesktop = { - autoStart = true; - privateNetwork = false; - specialArgs = { inherit username stateVersion desktop; }; - config = { config, pkgs, lib, username, stateVersion, desktop, ... }: { - networking.hostName = "nixos-rdesktop"; - system.stateVersion = stateVersion; - - imports = [ - ../common/desktops/${desktop} - ../users/${username} - ]; - - networking.firewall = { - enable = true; - allowedTCPPorts = [ 3390 ]; - }; - - services.xrdp = { - enable = true; - openFirewall = true; - port = 3390; - defaultWindowManager = "xfce4-session"; - }; - }; - }; -} diff --git a/nixos/containers/rdesktop/default.nix b/nixos/containers/rdesktop/default.nix new file mode 100644 index 00000000..29f7972f --- /dev/null +++ b/nixos/containers/rdesktop/default.nix @@ -0,0 +1,18 @@ +{ username, stateVersion, desktop, ... }: { + imports = [ + ../../common/desktops/${desktop} + ../../users/${username} + ]; + + networking.firewall = { + enable = true; + allowedTCPPorts = [ 3390 ]; + }; + + services.xrdp = { + enable = true; + openFirewall = true; + port = 3390; + defaultWindowManager = "xfce4-session"; + }; +} diff --git a/nixos/hosts/framework-server/containers.nix b/nixos/hosts/framework-server/containers.nix new file mode 100644 index 00000000..675f7224 --- /dev/null +++ b/nixos/hosts/framework-server/containers.nix @@ -0,0 +1,8 @@ +{ self, inputs, outputs, username, stateVersion, hmStateVersion, config, lib, pkgs, modulesPath, system, ... }: +let + libx = import ../../../lib {inherit self inputs outputs stateVersion hmStateVersion; }; +in { + containers = { + rdesktop = libx.mkContainer { container = "rdesktop"; }; + }; +} diff --git a/nixos/hosts/framework-server/default.nix b/nixos/hosts/framework-server/default.nix index 6ee7b732..ca6aa49d 100644 --- a/nixos/hosts/framework-server/default.nix +++ b/nixos/hosts/framework-server/default.nix @@ -1,4 +1,4 @@ -{ username, stateVersion, inputs, config, lib, pkgs, modulesPath, system, ... }: { +{ self, inputs, outputs, username, stateVersion, hmStateVersion, config, lib, pkgs, modulesPath, system, ... }: { imports = [ inputs.nixos-hardware.nixosModules.framework-13th-gen-intel (modulesPath + "/installer/scan/not-detected.nix") @@ -8,7 +8,7 @@ ../../common/modules/ssh-luks.nix ../../common/services/docker.nix ../../common/services/tailscale-autoconnect.nix - ( import ../../containers/rdesktop.nix { desktop = "xfce"; stateVersion = stateVersion; username = username;} ) + ./containers.nix ./disks.nix ./builder.nix ./wireguard.nix @@ -16,10 +16,10 @@ ./firewall.nix ]; - environment.systemPackages = [ - inputs.deploy-rs.packages.${system}.deploy-rs - pkgs.distrobox - ]; + environment.systemPackages = [ + inputs.deploy-rs.packages.${system}.deploy-rs + pkgs.distrobox + ]; # backups-rpi4 cron job to back up sysctl.io's Docker files # osaka-linode-01 cron job to copy certs for the DERP relay