From bfddea286a25200068a1a3e9eea57a9e84b7ae50 Mon Sep 17 00:00:00 2001 From: Daniel Olsen Date: Fri, 3 Jun 2022 12:22:24 +0200 Subject: [PATCH] simplify activation, reduce closure size of base --- .gitignore | 1 + flake.nix | 19 ++++++++++++--- machines/desktop.nix | 1 + machines/headless.nix | 18 ++++++++++++++ machines/laptop.nix | 1 + machines/pvv-terminal.nix | 1 + profiles/base/default.nix | 51 +++++++++++++-------------------------- 7 files changed, 54 insertions(+), 38 deletions(-) create mode 100644 .gitignore create mode 100644 machines/headless.nix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b2be92b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +result diff --git a/flake.nix b/flake.nix index 33e6367..5e692f0 100644 --- a/flake.nix +++ b/flake.nix @@ -32,14 +32,18 @@ hmChannel.lib.homeManagerConfiguration { inherit configuration system username homeDirectory stateVersion extraSpecialArgs; }; + + mkHomes = machines: extraArgs: nixlib.genAttrs machines (machine: mkHome {inherit machine; } // extraArgs); + + allMachines = [ "laptop" "desktop" "headless" "pvv-terminal" ]; in { - homeConfigurations = nixlib.genAttrs [ "laptop" ] (machine: mkHome { inherit machine; }) - // nixlib.genAttrs [ "desktop" ] (machine: mkHome { inherit machine; username = "dan"; }) - // nixlib.genAttrs [ "pvv-terminal" ] (machine: mkHome {inherit machine; username = "danio"; homeDirectory = "/home/pvv/d/danio";}); + homeConfigurations = mkHomes [ "laptop" "headless" ] { } + // mkHomes [ "desktop" ] { username = "dan"; } + // mkHomes [ "pvv-terminal" ] { username = "danio"; homeDirectory = "/home/pvv/d/danio"; }; nixosModules = { - home-manager = nixlib.genAttrs [ "laptop" "desktop" "pvv-terminal" ] (machine: import ./machines/${machine}.nix); + home-manager = nixlib.genAttrs allMachines (machine: import ./machines/${machine}.nix); }; overlays = [ @@ -51,5 +55,12 @@ }) nur.overlay ]; + + homeActivations = nixlib.genAttrs allMachines (machine: self.homeConfigurations.${machine}.activationPackage); + + apps.x86_64-linux = nixlib.genAttrs allMachines (machine: { + type = "app"; + program = "${self.homeActivations.${machine}}/activate"; + }); }; } diff --git a/machines/desktop.nix b/machines/desktop.nix index ad946ec..6df8633 100644 --- a/machines/desktop.nix +++ b/machines/desktop.nix @@ -13,6 +13,7 @@ secondary-fs = "/mnt/henning"; }; profiles.base.enable = true; + profiles.base.plus = true; profiles.xsession.enable = true; profiles.zsh.enable = true; diff --git a/machines/headless.nix b/machines/headless.nix new file mode 100644 index 0000000..33c242d --- /dev/null +++ b/machines/headless.nix @@ -0,0 +1,18 @@ +{ config, lib, pkgs, overlays, ... }: +{ + nixpkgs.overlays = overlays; + + imports = [ ../profiles ]; + + machine = { + name = "Headless"; + eth = null; + wlan = null; + secondary-fs = null; + }; + + profiles.base.enable = true; + profiles.base.enable = false; + + profiles.zsh.enable = true; +} diff --git a/machines/laptop.nix b/machines/laptop.nix index be2f8ea..1d1005e 100644 --- a/machines/laptop.nix +++ b/machines/laptop.nix @@ -12,6 +12,7 @@ wlan = "wlp5s0"; }; profiles.base.enable = true; + profiles.base.plus = true; profiles.gui.enable = true; profiles.xsession.enable = true; profiles.zsh.enable = true; diff --git a/machines/pvv-terminal.nix b/machines/pvv-terminal.nix index 3d1be62..a2f652d 100644 --- a/machines/pvv-terminal.nix +++ b/machines/pvv-terminal.nix @@ -12,6 +12,7 @@ secondary-fs = null; }; profiles.base.enable = true; + profiles.base.plus = false; profiles.gui.enable = true; profiles.non-nixos.enable = true; profiles.xsession.enable = true; diff --git a/profiles/base/default.nix b/profiles/base/default.nix index 0308ae0..879586e 100644 --- a/profiles/base/default.nix +++ b/profiles/base/default.nix @@ -19,15 +19,12 @@ in { options.profiles.base = { enable = lib.mkEnableOption "The base profile, should be always enabled"; + plus = lib.mkEnableOption "Useful things you arguably don't NEED"; }; config = lib.mkIf cfg.enable { home.packages = with pkgs; [ - #libguestfs - #ansible - #nixops - nix-output-monitor nix-top nix-index @@ -55,24 +52,12 @@ in { bat exa ripgrep - - mkvtoolnix -# unstable.youtubeDL + ] ++ lib.optionals cfg.plus [ ffmpeg-full ] ++ lib.optionals config.profiles.gui.enable [ -# virtmanager -# virt-viewer - - thunderbird - mpv sxiv - mumble - - #dan.rank_photos - - dolphin plasma5Packages.dolphin-plugins ffmpegthumbs plasma5Packages.kdegraphics-thumbnailers @@ -82,22 +67,24 @@ in { gnome3.gedit vscodium + + gimp + ] ++ lib.optionals (config.profiles.gui.enable && cfg.plus) [ + mumble + # texlive.combined.scheme-full # kile libreoffice - - gimp -# krita -# inkscape -# digikam -# godot -# blender -# audacity -# mixxx -# ardour + thunderbird + kdenlive frei0r - ] ++ lib.optionals (config.nixpkgs.config.allowUnfree && config.profiles.gui.enable) [ + audacity + inkscape + blender + + mkvtoolnix + ] ++ lib.optionals (config.nixpkgs.config.allowUnfree && config.profiles.gui.enable) [ geogebra ]; @@ -127,7 +114,7 @@ in { extensions = with pkgs.nur.repos.rycee.firefox-addons; [ bitwarden cookies-txt https-everywhere metamask no-pdf-download sponsorblock ublock-origin ]; }; - programs.obs-studio.enable = config.profiles.gui.enable; + programs.obs-studio.enable = (config.profiles.gui.enable && cfg.plus); programs.git = { @@ -150,6 +137,7 @@ in { }; "desktop" = { hostname = "10.42.42.10"; + proxyJump = "lilith"; user = "dan"; }; "laptop" = { @@ -173,11 +161,6 @@ in { }; }; -# services.kdeconnect = { -# enable = true; -# indicator = true; -# }; - services.gpg-agent = { enable = true; defaultCacheTtl = 1800;