From b71bb5794a0a8a10f9d5e1995f64a225a821a7e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Schwarz=C3=A4ugl?= Date: Sat, 28 Dec 2024 23:59:43 +0100 Subject: [PATCH] refactor: lib, flake.nix --- SwarselSystems.org | 426 +++++++----------- flake.nix | 157 +++---- hosts/android/magicant/default.nix | 44 ++ hosts/home-manager/default/default.nix | 25 +- hosts/home/default/default.nix | 55 +++ index.html | 282 ++++-------- lib/default.nix | 84 +++- modules/home/default.nix | 11 +- modules/home/filesystem.nix | 1 - modules/home/hardware.nix | 1 - modules/home/input.nix | 27 +- modules/home/monitors.nix | 19 +- modules/home/nixos.nix | 5 +- modules/home/startup.nix | 8 +- modules/home/wallpaper.nix | 1 - modules/home/waybar.nix | 1 - modules/nixos/default.nix | 11 +- modules/nixos/input.nix | 7 +- overlays/default.nix | 29 +- pkgs/default.nix | 12 +- .../default.nix | 4 +- profiles/common/home/custom-packages.nix | 2 +- profiles/common/home/sops.nix | 8 +- profiles/common/home/sway.nix | 12 +- profiles/common/nixos/impermanence.nix | 4 +- profiles/common/nixos/sops.nix | 10 +- .../{bootstrap.sh => swarsel-bootstrap.sh} | 0 27 files changed, 540 insertions(+), 706 deletions(-) create mode 100644 hosts/android/magicant/default.nix create mode 100644 hosts/home/default/default.nix rename pkgs/{bootstrap => swarsel-bootstrap}/default.nix (50%) rename scripts/{bootstrap.sh => swarsel-bootstrap.sh} (100%) diff --git a/SwarselSystems.org b/SwarselSystems.org index f9533a9..f09a0c6 100644 --- a/SwarselSystems.org +++ b/SwarselSystems.org @@ -714,16 +714,16 @@ In =outputs = inputs@ [...]=, the =inputs@= makes it so that all inputs are auto nixosConfigurations = <> - homeConfigurations = { + homeConfigurations = <> - }; + darwinConfigurations = <> - nixOnDroidConfigurations = { + nixOnDroidConfigurations = <> - }; + topology = <> @@ -965,70 +965,33 @@ The interesting part is in the start: #+begin_src nix :tangle no :noweb-ref flakelet - inherit (self) outputs; - lib = nixpkgs.lib // home-manager.lib; + inherit (self) outputs; + lib = (nixpkgs.lib // home-manager.lib).extend (_: _: { swarselsystems = import ./lib { inherit self lib inputs outputs systems; }; }); - pkgsFor = lib.genAttrs (import systems) ( - system: - import nixpkgs { - inherit system; - config.allowUnfree = true; - } - ); - forEachSystem = f: lib.genAttrs (import systems) (system: f pkgsFor.${system}); - forAllSystems = lib.genAttrs [ - "x86_64-linux" - "aarch64-linux" - "x86_64-darwin" - "aarch64-darwin" - ]; - mkFullHost = host: isNixos: { - ${host} = - let - func = if isNixos then lib.nixosSystem else inputs.nix-darwin.lib.darwinSystem; - systemFunc = func; - in - systemFunc { - specialArgs = { - inherit inputs outputs self; - lib = lib.extend (_: _: { swarselsystems = import ./lib { inherit lib; }; }); - }; - modules = [ ./hosts/${if isNixos then "nixos" else "darwin"}/${host} ]; - }; - }; - mkFullHostConfigs = hosts: isNixos: lib.foldl (acc: set: acc // set) { } (lib.map (host: mkFullHost host isNixos) hosts); - readHosts = folder: lib.attrNames (builtins.readDir ./hosts/${folder}); - # NixOS modules that can only be used on NixOS systems - nixModules = [ - inputs.stylix.nixosModules.stylix - inputs.lanzaboote.nixosModules.lanzaboote - inputs.disko.nixosModules.disko - inputs.impermanence.nixosModules.impermanence - inputs.sops-nix.nixosModules.sops - inputs.nswitch-rcm-nix.nixosModules.nswitch-rcm - inputs.nix-topology.nixosModules.default - ./profiles/common/nixos - ]; + # NixOS modules that can only be used on NixOS systems + nixModules = [ + inputs.stylix.nixosModules.stylix + inputs.lanzaboote.nixosModules.lanzaboote + inputs.disko.nixosModules.disko + inputs.impermanence.nixosModules.impermanence + inputs.sops-nix.nixosModules.sops + inputs.nswitch-rcm-nix.nixosModules.nswitch-rcm + inputs.nix-topology.nixosModules.default + ./profiles/common/nixos + ]; - # Home-Manager modules wanted on non-NixOS systems - homeModules = [ - inputs.stylix.homeManagerModules.stylix - ]; + # Home-Manager modules wanted on non-NixOS systems + homeModules = [ + inputs.stylix.homeManagerModules.stylix + ]; - # Home-Manager modules wanted on both NixOS and non-NixOS systems - mixedModules = [ - inputs.sops-nix.homeManagerModules.sops - inputs.nix-index-database.hmModules.nix-index - ./profiles/common/home - ]; - - # For adding things to _module.args (making arguments available globally) - # moduleArgs = [ - # { - # _module.args = { inherit self; }; - # } - # ]; + # Home-Manager modules wanted on both NixOS and non-NixOS systems + mixedModules = [ + inputs.sops-nix.homeManagerModules.sops + inputs.nix-index-database.hmModules.nix-index + ./profiles/common/home + ]; #+end_src ** General (outputs) @@ -1053,69 +1016,61 @@ In this section I am creating some attributes that define general concepts of my #+begin_src nix :tangle no :noweb-ref flakeoutputgeneral - inherit lib; - inherit mixedModules; - inherit nixModules; + inherit lib nixModules mixedModules homeModules; - nixosModules = import ./modules/nixos; - homeManagerModules = import ./modules/home; + nixosModules = import ./modules/nixos { inherit lib; }; + homeManagerModules = import ./modules/home { inherit lib; }; + packages = lib.swarselsystems.forEachSystem (pkgs: import ./pkgs { inherit lib pkgs; }); + formatter = lib.swarselsystems.forEachSystem (pkgs: pkgs.nixpkgs-fmt); + overlays = import ./overlays { inherit self lib inputs; }; - packages = forEachSystem (pkgs: import ./pkgs { inherit pkgs; }); - apps = forAllSystems (system: { - default = self.apps.${system}.bootstrap; + apps = lib.swarselsystems.forAllSystems (system: + let + appNames = [ + "swarsel-bootstrap" + "swarsel-install" + "swarsel-rebuild" + "swarsel-postinstall" + ]; + appSet = lib.swarselsystems.mkApps system appNames self; + in + { + inherit appSet; + default = appSet.bootstrap; + }); - bootstrap = { - type = "app"; - program = "${self.packages.${system}.bootstrap}/bin/bootstrap"; - }; - - install = { - type = "app"; - program = "${self.packages.${system}.swarsel-install}/bin/swarsel-install"; - }; - - postinstall = { - type = "app"; - program = "${self.packages.${system}.swarsel-postinstall}/bin/swarsel-postinstall"; - }; - - rebuild = { - type = "app"; - program = "${self.packages.${system}.swarsel-rebuild}/bin/swarsel-rebuild"; - }; - }); - devShells = forAllSystems ( - system: + devShells = lib.swarselsystems.forAllSystems (system: let pkgs = nixpkgs.legacyPackages.${system}; checks = self.checks.${system}; in - { - default = pkgs.mkShell { - NIX_CONFIG = "experimental-features = nix-command flakes"; - inherit (checks.pre-commit-check) shellHook; - buildInputs = checks.pre-commit-check.enabledPackages; - nativeBuildInputs = [ - pkgs.nix - pkgs.home-manager - pkgs.git - pkgs.just - pkgs.age - pkgs.ssh-to-age - pkgs.sops - ]; - }; - }); - - formatter = forEachSystem (pkgs: pkgs.nixpkgs-fmt); - checks = forAllSystems ( - system: - let - pkgs = nixpkgs.legacyPackages.${system}; - in - import ./checks { inherit self inputs system pkgs; } + { + default = pkgs.mkShell { + NIX_CONFIG = "experimental-features = nix-command flakes"; + inherit (checks.pre-commit-check) shellHook; + buildInputs = checks.pre-commit-check.enabledPackages; + nativeBuildInputs = with pkgs; [ + nix + home-manager + git + just + age + ssh-to-age + sops + statix + deadnix + nixpkgs-fmt + ]; + }; + } + ); + + checks = lib.swarselsystems.forAllSystems (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + import ./checks { inherit self inputs system pkgs; } ); - overlays = import ./overlays { inherit inputs; }; #+end_src @@ -1131,7 +1086,7 @@ Note: The preceding =nixosConfigurations= is found in [[#h:aee5ec75-7ca6-40d8-b6 #+begin_src nix :tangle no :noweb-ref flakenixosconf - mkFullHostConfigs (readHosts "nixos") true; + lib.swarselsystems.mkFullHostConfigs (lib.swarselsystems.readHosts "nixos") "nixos"; #+end_src ** darwinConfigurations :PROPERTIES: @@ -1144,7 +1099,7 @@ Note: The preceding =darwinConfigurations= is found in [[#h:aee5ec75-7ca6-40d8-b =3a272b1 feat!: dynamically create hosts=, and the deprecated system definitions removed in =7457109 main chore: remove deprecated static host config=. See those commits for a state with a simpler config. #+begin_src nix :tangle no :noweb-ref flakedarwinconf - mkFullHostConfigs (readHosts "darwin") false; + lib.swarselsystems.mkFullHostConfigs (lib.swarselsystems.readHosts "darwin") "darwin"; #+end_src ** homeConfigurations @@ -1156,14 +1111,15 @@ In contrast, this defines home-manager systems, which I only have one of, that s #+begin_src nix :tangle no :noweb-ref flakehomeconf - "swarsel@home-manager" = inputs.home-manager.lib.homeManagerConfiguration { - pkgs = pkgsFor.x86_64-linux; - extraSpecialArgs = { inherit inputs outputs; }; - modules = homeModules ++ mixedModules ++ [ - ./hosts/home-manager - ]; - }; + # "swarsel@home-manager" = inputs.home-manager.lib.homeManagerConfiguration { + # pkgs = lib.swarselsystems.pkgsFor.x86_64-linux; + # extraSpecialArgs = { inherit inputs outputs; }; + # modules = homeModules ++ mixedModules ++ [ + # ./hosts/home-manager + # ]; + # }; + lib.swarselsystems.mkHalfHostConfigs (lib.swarselsystems.readHosts "home") "home" lib.swarselsystems.pkgsFor.x86_64-linux; #+end_src ** nixOnDroidConfigurations @@ -1175,12 +1131,14 @@ Nix on Android also demands an own flake output, which is provided here. #+begin_src nix :tangle no :noweb-ref flakedroidconf - magicant = inputs.nix-on-droid.lib.nixOnDroidConfiguration { - pkgs = pkgsFor.aarch64-linux; - modules = [ - ./hosts/magicant - ]; - }; + # magicant = inputs.nix-on-droid.lib.nixOnDroidConfiguration { + # pkgs = lib.swarselsystems.pkgsFor.aarch64-linux; + # modules = [ + # ./hosts/magicant + # ]; + # }; + + lib.swarselsystems.mkHalfHostConfigs (lib.swarselsystems.readHosts "android") "android" lib.swarselsystems.pkgsFor.aarch64-linux; #+end_src @@ -1189,7 +1147,7 @@ Nix on Android also demands an own flake output, which is provided here. #+begin_src nix :tangle no :noweb-ref topologyconf - forEachSystem (pkgs: import inputs.nix-topology { + lib.swarselsystems.forEachSystem (pkgs: import inputs.nix-topology { inherit pkgs; modules = [ # Your own file to define global topology. Works in principle like a nixos module but uses different options. @@ -2010,7 +1968,7 @@ This is the "reference implementation" of a setup that runs without NixOS, only { self, inputs, outputs, config, ... }: { - imports = builtins.attrValues outputs.homeManagerModules; + imports = outputs.homeModules ++ outputs.mixedModules ++ (builtins.attrValues outputs.homeManagerModules); nixpkgs = { overlays = [ outputs.overlays.default ]; @@ -2036,29 +1994,6 @@ This is the "reference implementation" of a setup that runs without NixOS, only isLaptop = true; isNixos = false; wallpaper = self + /wallpaper/surfacewp.png; - temperatureHwmon = { - isAbsolutePath = true; - path = "/sys/devices/platform/thinkpad_hwmon/hwmon/"; - input-filename = "temp1_input"; - }; - monitors = { - main = { - name = "California Institute of Technology 0x1407 Unknown"; - mode = "1920x1080"; # TEMPLATE - scale = "1"; - position = "2560,0"; - workspace = "2:二"; - output = "eDP-1"; - }; - }; - inputs = { - "1:1:AT_Translated_Set_2_keyboard" = { - xkb_layout = "us"; - xkb_options = "grp:win_space_toggle"; - xkb_variant = "altgr-intl"; - }; - }; - keybindings = { }; }; } @@ -2160,7 +2095,7 @@ This is the central station for self-defined packages. These are all referenced Note: The structure of generating the packages was changed in commit =2cf03a3 refactor: package and module generation=. That commit can be checked out in order to see a simpler version of achieving the same thing. #+begin_src nix :tangle pkgs/default.nix - { pkgs, ... }: + { lib, pkgs, ... }: let packageNames = [ "pass-fuzzel" @@ -2178,7 +2113,7 @@ Note: The structure of generating the packages was changed in commit =2cf03a3 re "update-checker" "github-notifications" "screenshare" - "bootstrap" + "swarsel-bootstrap" "swarsel-rebuild" "swarsel-install" "swarsel-postinstall" @@ -2187,12 +2122,8 @@ Note: The structure of generating the packages was changed in commit =2cf03a3 re "vershell" "eontimer" ]; - mkPackages = names: builtins.listToAttrs (map (name: { - inherit name; - value = pkgs.callPackage ./${name} { }; - }) names); in - mkPackages packageNames + lib.swarselsystems.mkPackages packageNames pkgs #+end_src @@ -2793,14 +2724,14 @@ This utility checks if there are updated packages in nixpkgs-unstable. It does s } #+end_src -**** bootstrap +**** swarsel-bootstrap :PROPERTIES: :CUSTOM_ID: h:74db57ae-0bb9-4257-84be-eddbc85130dd :END: This program sets up a new NixOS host remotely. It also takes care of secret management on the new host. -#+begin_src shell :tangle scripts/bootstrap.sh +#+begin_src shell :tangle scripts/swarsel-bootstrap.sh # highly inspired by https://github.com/EmergentMind/nix-config/blob/dev/scripts/bootstrap-nixos.sh set -eo pipefail @@ -3143,13 +3074,13 @@ This program sets up a new NixOS host remotely. It also takes care of secret man #+end_src -#+begin_src nix :tangle pkgs/bootstrap/default.nix +#+begin_src nix :tangle pkgs/swarsel-bootstrap/default.nix { writeShellApplication, openssh }: writeShellApplication { - name = "bootstrap"; + name = "swarsel-bootstrap"; runtimeInputs = [ openssh ]; - text = builtins.readFile ../../scripts/bootstrap.sh; + text = builtins.readFile ../../scripts/swarsel-bootstrap.sh; } #+end_src @@ -3659,24 +3590,25 @@ This file now holds all of the "nixpkgs-changes" that I am using across the conf When adding a new entry here, do not forget to add it in the default output of this file, otherwise it will not be exposed to the rest of the system. #+begin_src nix :tangle overlays/default.nix - { inputs, ... }: + { self,inputs, lib, ... }: let - additions = final: _prev: import ../pkgs { pkgs = final; }; - modifications = _: _prev: { - vesktop = _prev.vesktop.override { + additions = final: _: import "${self}/pkgs" { pkgs = final; inherit lib; }; + + modifications = _: prev: { + vesktop = prev.vesktop.override { withSystemVencord = true; }; - firefox = _prev.firefox.override { + firefox = prev.firefox.override { nativeMessagingHosts = [ - _prev.tridactyl-native - _prev.browserpass - _prev.plasma5Packages.plasma-browser-integration + prev.tridactyl-native + prev.browserpass + prev.plasma5Packages.plasma-browser-integration ]; }; - retroarch = _prev.retroarch.withCores (cores: with cores; [ + retroarch = prev.retroarch.withCores (cores: with cores; [ snes9x # snes nestopia # nes dosbox # dos @@ -3687,10 +3619,6 @@ When adding a new entry here, do not forget to add it in the default output of t dolphin # gc/wii ]); - # prismlauncher = _prev.prismlauncher.override { - # glfw = _prev.glfw-wayland-minecraft; - # }; - # #river = prev.river.overrideAttrs (oldAttrs: rec { # pname = "river"; # version = "git"; @@ -3704,15 +3632,15 @@ When adding a new entry here, do not forget to add it in the default output of t # }); }; - nixpkgs-stable = final: _prev: { + nixpkgs-stable = final: _: { stable = import inputs.nixpkgs-stable { inherit (final) system; config.allowUnfree = true; }; }; - zjstatus = _: _prev: { - zjstatus = inputs.zjstatus.packages.${_prev.system}.default; + zjstatus = _: prev: { + zjstatus = inputs.zjstatus.packages.${prev.system}.default; }; in @@ -3750,6 +3678,7 @@ Note: The structure of generating the packages was changed in commit =2cf03a3 re Modules that need to be loaded on the NixOS level. Note that these will not be available on systems that are not running NixOS. #+begin_src nix :tangle modules/nixos/default.nix + { lib, ... }: let moduleNames = [ "wallpaper" @@ -3758,14 +3687,8 @@ Modules that need to be loaded on the NixOS level. Note that these will not be a "server" "input" ]; - - mkImports = names: builtins.listToAttrs (map (name: { - inherit name; - value = import ./${name}.nix; - }) names); - in - mkImports moduleNames + lib.swarselsystems.mkModules moduleNames "nixos" #+end_src @@ -3890,12 +3813,9 @@ This section is for everything input-related on the NixOS side. At the moment, t #+begin_src nix :tangle modules/nixos/input.nix { lib, ... }: - let - inherit (lib) mkOption types; - in { - options.swarselsystems.shellAliases = mkOption { - type = types.attrsOf types.str; + options.swarselsystems.shellAliases = lib.mkOption { + type = lib.types.attrsOf lib.types.str; default = { }; }; } @@ -3909,6 +3829,7 @@ This section is for everything input-related on the NixOS side. At the moment, t This holds modules that are to be used on most hosts. These are also the most important options to configure, as these allow me easy access to monitor, keyboard, and other setups. #+BEGIN_src nix :tangle modules/home/default.nix + { lib, ... }: let moduleNames = [ "laptop" @@ -3923,14 +3844,8 @@ This holds modules that are to be used on most hosts. These are also the most im "filesystem" "firefox" ]; - - mkImports = names: builtins.listToAttrs (map (name: { - inherit name; - value = import ./${name}.nix; - }) names); - in - mkImports moduleNames + lib.swarselsystems.mkModules moduleNames "home" #+end_src ***** Laptop @@ -3981,7 +3896,6 @@ This section is mostly used to deliver the correct information to Waybar. AMD sy #+begin_src nix :tangle modules/home/hardware.nix { lib, ... }: - { options.swarselsystems.cpuCount = lib.mkOption { type = lib.types.int; @@ -4010,7 +3924,6 @@ The most part of this configuration is done here: [[#h:0bf51f63-01c0-4053-a591-7 #+begin_src nix :tangle modules/home/waybar.nix { lib, config, ... }: - let generateIcons = n: lib.concatStringsSep " " (builtins.map (x: "{icon" + toString x + "}") (lib.range 0 (n - 1))); in @@ -4054,24 +3967,21 @@ This allows me to define my monitors in the machine's =default.nix=. #+begin_src nix :tangle modules/home/monitors.nix { lib, ... }: - let - inherit (lib) mkOption types; - in { - options.swarselsystems.monitors = mkOption { - type = types.attrsOf (types.attrsOf types.str); + options.swarselsystems.monitors = lib.mkOption { + type = lib.types.attrsOf (lib.types.attrsOf lib.types.str); default = { }; }; - options.swarselsystems.sharescreen = mkOption { - type = types.str; + options.swarselsystems.sharescreen = lib.mkOption { + type = lib.types.str; default = ""; }; - options.swarselsystems.lowResolution = mkOption { - type = types.str; + options.swarselsystems.lowResolution = lib.mkOption { + type = lib.types.str; default = ""; }; - options.swarselsystems.highResolution = mkOption { - type = types.str; + options.swarselsystems.highResolution = lib.mkOption { + type = lib.types.str; default = ""; }; } @@ -4086,16 +3996,13 @@ This allows me to configure input options. Here, I am globally defining my split #+begin_src nix :tangle modules/home/input.nix { lib, config, ... }: - let - inherit (lib) mkOption types; - in { - options.swarselsystems.inputs = mkOption { - type = types.attrsOf (types.attrsOf types.str); + options.swarselsystems.inputs = lib.mkOption { + type = lib.types.attrsOf (lib.types.attrsOf lib.types.str); default = { }; }; - options.swarselsystems.kyria = mkOption { - type = types.attrsOf (types.attrsOf types.str); + options.swarselsystems.kyria = lib.mkOption { + type = lib.types.attrsOf (lib.types.attrsOf lib.types.str); default = { "36125:53060:splitkb.com_splitkb.com_Kyria_rev3" = { xkb_layout = "us"; @@ -4107,21 +4014,21 @@ This allows me to configure input options. Here, I am globally defining my split }; }; }; - options.swarselsystems.touchpad = mkOption { - type = types.attrsOf (types.attrsOf types.str); + options.swarselsystems.touchpad = lib.mkOption { + type = lib.types.attrsOf (lib.types.attrsOf lib.types.str); default = { }; }; - options.swarselsystems.standardinputs = mkOption { - type = types.attrsOf (types.attrsOf types.str); + options.swarselsystems.standardinputs = lib.mkOption { + type = lib.types.attrsOf (lib.types.attrsOf lib.types.str); default = lib.recursiveUpdate (lib.recursiveUpdate config.swarselsystems.touchpad config.swarselsystems.kyria) config.swarselsystems.inputs; internal = true; }; - options.swarselsystems.keybindings = mkOption { - type = types.attrsOf types.str; + options.swarselsystems.keybindings = lib.mkOption { + type = lib.types.attrsOf lib.types.str; default = { }; }; - options.swarselsystems.shellAliases = mkOption { - type = types.attrsOf types.str; + options.swarselsystems.shellAliases = lib.mkOption { + type = lib.types.attrsOf lib.types.str; default = { }; }; } @@ -4144,9 +4051,7 @@ These are some extra options that will be used if the machine also runs NixOS. F options.swarselsystems.isNixos = lib.mkEnableOption "nixos host"; options.swarselsystems.isPublic = lib.mkEnableOption "is a public machine (no secrets)"; config.swarselsystems.startup = lib.mkIf (!config.swarselsystems.isNixos) [ - { - command = "sleep 60 && nixGL nextcloud --background"; - } + { command = "sleep 60 && nixGL nextcloud --background"; } { command = "sleep 60 && nixGL vesktop --start-minimized -enable-features=UseOzonePlatform -ozone-platform=wayland"; } { command = "sleep 60 && nixGL syncthingtray --wait"; } { command = "sleep 60 && ANKI_WAYLAND=1 nixGL anki"; } @@ -4154,6 +4059,7 @@ These are some extra options that will be used if the machine also runs NixOS. F { command = "sleep 60 && OBSIDIAN_USE_WAYLAND=1 nixGL obsidian -enable-features=UseOzonePlatform -ozone-platform=wayland"; } { command = "sleep 60 && element-desktop --hidden -enable-features=UseOzonePlatform -ozone-platform=wayland --disable-gpu-driver-bug-workarounds"; } ]; + options.swarselsystems.swayfxConfig = lib.mkOption { type = lib.types.str; default = " @@ -4203,13 +4109,9 @@ Do not that =syncthingtray= is also not mentioned here. It is installed as a hom #+begin_src nix :tangle modules/home/startup.nix { lib, ... }: -let - inherit (lib) mkOption types; -in { - - options.swarselsystems.startup = mkOption { - type = types.listOf (types.attrsOf types.str); + options.swarselsystems.startup = lib.mkOption { + type = lib.types.listOf (lib.types.attrsOf lib.types.str); default = [ { command = "nextcloud --background"; } { command = "vesktop --start-minimized --enable-speech-dispatcher --ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime"; } @@ -4232,7 +4134,6 @@ Again, I set the wallpaper here for =stylix=. #+begin_src nix :tangle modules/home/wallpaper.nix { lib, ... }: - { options.swarselsystems.wallpaper = lib.mkOption { type = lib.types.path; @@ -4251,7 +4152,6 @@ Another duplicated option for the filesystem. #+begin_src nix :tangle modules/home/filesystem.nix { lib, ... }: - { options.swarselsystems.isBtrfs = lib.mkEnableOption "use btrfs filesystem"; } @@ -5210,17 +5110,11 @@ I use sops-nix to handle secrets that I want to have available on my machines at #+begin_src nix :tangle profiles/common/nixos/sops.nix { config, lib, ... }: - let - mkIfElse = p: yes: no: lib.mkMerge [ - (lib.mkIf p yes) - (lib.mkIf (!p) no) - ]; - in { sops = lib.mkIf (!config.swarselsystems.isPublic) { - age.sshKeyPaths = mkIfElse config.swarselsystems.isBtrfs [ "/persist/.ssh/sops" "/persist/.ssh/ssh_host_ed25519_key" ] [ "${config.users.users.swarsel.home}/.ssh/sops" "/etc/ssh/ssh_host_ed25519_key" ]; - defaultSopsFile = mkIfElse config.swarselsystems.isBtrfs "/persist/.dotfiles/secrets/general/secrets.yaml" "${config.users.users.swarsel.home}/.dotfiles/secrets/general/secrets.yaml"; + age.sshKeyPaths = lib.swarselsystems.mkIfElseList config.swarselsystems.isBtrfs [ "/persist/.ssh/sops" "/persist/.ssh/ssh_host_ed25519_key" ] [ "${config.users.users.swarsel.home}/.ssh/sops" "/etc/ssh/ssh_host_ed25519_key" ]; + defaultSopsFile = lib.swarselsystems.mkIfElseList config.swarselsystems.isBtrfs "/persist/.dotfiles/secrets/general/secrets.yaml" "${config.users.users.swarsel.home}/.dotfiles/secrets/general/secrets.yaml"; validateSopsFiles = false; @@ -5751,10 +5645,8 @@ Normally, doing that also resets the lecture that happens on the first use of =s #+begin_src nix :tangle profiles/common/nixos/impermanence.nix { config, lib, ... }: let - mkIfElse = p: yes: no: if p then yes else no; - mapperTarget = mkIfElse config.swarselsystems.isCrypted "/dev/mapper/cryptroot" "/dev/disk/by-label/nixos"; + mapperTarget = lib.swarselsystems.mkIfElse config.swarselsystems.isCrypted "/dev/mapper/cryptroot" "/dev/disk/by-label/nixos"; in - { security.sudo.extraConfig = lib.mkIf config.swarselsystems.isImpermanence '' @@ -8526,7 +8418,7 @@ This is just a separate container for derivations defined in [[#h:64a5cc16-6b16- vershell eontimer - bootstrap + swarsel-bootstrap (pkgs.writeScriptBin "project" '' #! ${pkgs.bash}/bin/bash @@ -8581,16 +8473,10 @@ I use sops-nix to handle secrets that I want to have available on my machines at #+begin_src nix :tangle profiles/common/home/sops.nix { config, lib, ... }: - let - mkIfElse = p: yes: no: lib.mkMerge [ - (lib.mkIf p yes) - (lib.mkIf (!p) no) - ]; - in { sops = lib.mkIf (!config.swarselsystems.isPublic) { age.sshKeyPaths = [ "${config.home.homeDirectory}/.ssh/sops" "${config.home.homeDirectory}/.ssh/ssh_host_ed25519_key" ]; - defaultSopsFile = mkIfElse config.swarselsystems.isBtrfs "/persist/.dotfiles/secrets/general/secrets.yaml" "${config.home.homeDirectory}/.dotfiles/secrets/general/secrets.yaml"; + defaultSopsFile = lib.swarselsystems.mkIfElseList config.swarselsystems.isBtrfs "/persist/.dotfiles/secrets/general/secrets.yaml" "${config.home.homeDirectory}/.dotfiles/secrets/general/secrets.yaml"; validateSopsFiles = false; secrets = { @@ -10565,15 +10451,7 @@ Currently, I am too lazy to explain every option here, but most of it is very se { config, lib, ... }: let inherit (config.swarselsystems) monitors; - eachMonitor = _name: monitor: { - inherit (monitor) name; - value = builtins.removeAttrs monitor [ "workspace" "name" "output" ]; - }; - eachOutput = _name: monitor: { - inherit (monitor) name; - value = builtins.removeAttrs monitor [ "mode" "name" "scale" "transform" "position" ]; - }; - workplaceSets = lib.mapAttrs' eachOutput monitors; + workplaceSets = lib.mapAttrs' lib.swarselsystems.eachOutput monitors; workplaceOutputs = map (key: lib.getAttr key workplaceSets) (lib.attrNames workplaceSets); in { @@ -10699,7 +10577,7 @@ Currently, I am too lazy to explain every option here, but most of it is very se }; }; defaultWorkspace = "workspace 1:一"; - output = lib.mapAttrs' eachMonitor monitors; + output = lib.mapAttrs' lib.swarselsystems.eachMonitor monitors; input = config.swarselsystems.standardinputs; workspaceOutputAssign = workplaceOutputs; startup = config.swarselsystems.startup ++ [ diff --git a/flake.nix b/flake.nix index 2915b74..7d2230d 100644 --- a/flake.nix +++ b/flake.nix @@ -130,38 +130,8 @@ let inherit (self) outputs; - lib = nixpkgs.lib // home-manager.lib; + lib = (nixpkgs.lib // home-manager.lib).extend (_: _: { swarselsystems = import ./lib { inherit self lib inputs outputs systems; }; }); - pkgsFor = lib.genAttrs (import systems) ( - system: - import nixpkgs { - inherit system; - config.allowUnfree = true; - } - ); - forEachSystem = f: lib.genAttrs (import systems) (system: f pkgsFor.${system}); - forAllSystems = lib.genAttrs [ - "x86_64-linux" - "aarch64-linux" - "x86_64-darwin" - "aarch64-darwin" - ]; - mkFullHost = host: isNixos: { - ${host} = - let - func = if isNixos then lib.nixosSystem else inputs.nix-darwin.lib.darwinSystem; - systemFunc = func; - in - systemFunc { - specialArgs = { - inherit inputs outputs self; - lib = lib.extend (_: _: { swarselsystems = import ./lib { inherit lib; }; }); - }; - modules = [ ./hosts/${if isNixos then "nixos" else "darwin"}/${host} ]; - }; - }; - mkFullHostConfigs = hosts: isNixos: lib.foldl (acc: set: acc // set) { } (lib.map (host: mkFullHost host isNixos) hosts); - readHosts = folder: lib.attrNames (builtins.readDir ./hosts/${folder}); # NixOS modules that can only be used on NixOS systems nixModules = [ @@ -187,49 +157,33 @@ ./profiles/common/home ]; - # For adding things to _module.args (making arguments available globally) - # moduleArgs = [ - # { - # _module.args = { inherit self; }; - # } - # ]; - in { - inherit lib; - inherit mixedModules; - inherit nixModules; + inherit lib nixModules mixedModules homeModules; - nixosModules = import ./modules/nixos; - homeManagerModules = import ./modules/home; + nixosModules = import ./modules/nixos { inherit lib; }; + homeManagerModules = import ./modules/home { inherit lib; }; + packages = lib.swarselsystems.forEachSystem (pkgs: import ./pkgs { inherit lib pkgs; }); + formatter = lib.swarselsystems.forEachSystem (pkgs: pkgs.nixpkgs-fmt); + overlays = import ./overlays { inherit self lib inputs; }; - packages = forEachSystem (pkgs: import ./pkgs { inherit pkgs; }); - apps = forAllSystems (system: { - default = self.apps.${system}.bootstrap; + apps = lib.swarselsystems.forAllSystems (system: + let + appNames = [ + "swarsel-bootstrap" + "swarsel-install" + "swarsel-rebuild" + "swarsel-postinstall" + ]; + appSet = lib.swarselsystems.mkApps system appNames self; + in + { + inherit appSet; + default = appSet.bootstrap; + }); - bootstrap = { - type = "app"; - program = "${self.packages.${system}.bootstrap}/bin/bootstrap"; - }; - - install = { - type = "app"; - program = "${self.packages.${system}.swarsel-install}/bin/swarsel-install"; - }; - - postinstall = { - type = "app"; - program = "${self.packages.${system}.swarsel-postinstall}/bin/swarsel-postinstall"; - }; - - rebuild = { - type = "app"; - program = "${self.packages.${system}.swarsel-rebuild}/bin/swarsel-rebuild"; - }; - }); - devShells = forAllSystems ( - system: + devShells = lib.swarselsystems.forAllSystems (system: let pkgs = nixpkgs.legacyPackages.${system}; checks = self.checks.${system}; @@ -239,62 +193,65 @@ NIX_CONFIG = "experimental-features = nix-command flakes"; inherit (checks.pre-commit-check) shellHook; buildInputs = checks.pre-commit-check.enabledPackages; - nativeBuildInputs = [ - pkgs.nix - pkgs.home-manager - pkgs.git - pkgs.just - pkgs.age - pkgs.ssh-to-age - pkgs.sops + nativeBuildInputs = with pkgs; [ + nix + home-manager + git + just + age + ssh-to-age + sops + statix + deadnix + nixpkgs-fmt ]; }; } ); - formatter = forEachSystem (pkgs: pkgs.nixpkgs-fmt); - checks = forAllSystems ( - system: + checks = lib.swarselsystems.forAllSystems (system: let pkgs = nixpkgs.legacyPackages.${system}; in import ./checks { inherit self inputs system pkgs; } ); - overlays = import ./overlays { inherit inputs; }; nixosConfigurations = - mkFullHostConfigs (readHosts "nixos") true; + lib.swarselsystems.mkFullHostConfigs (lib.swarselsystems.readHosts "nixos") "nixos"; - homeConfigurations = { + homeConfigurations = - "swarsel@home-manager" = inputs.home-manager.lib.homeManagerConfiguration { - pkgs = pkgsFor.x86_64-linux; - extraSpecialArgs = { inherit inputs outputs; }; - modules = homeModules ++ mixedModules ++ [ - ./hosts/home-manager - ]; - }; + # "swarsel@home-manager" = inputs.home-manager.lib.homeManagerConfiguration { + # pkgs = lib.swarselsystems.pkgsFor.x86_64-linux; + # extraSpecialArgs = { inherit inputs outputs; }; + # modules = homeModules ++ mixedModules ++ [ + # ./hosts/home-manager + # ]; + # }; + + lib.swarselsystems.mkHalfHostConfigs (lib.swarselsystems.readHosts "home") "home" lib.swarselsystems.pkgsFor.x86_64-linux; - }; darwinConfigurations = - mkFullHostConfigs (readHosts "darwin") false; + lib.swarselsystems.mkFullHostConfigs (lib.swarselsystems.readHosts "darwin") "darwin"; - nixOnDroidConfigurations = { + nixOnDroidConfigurations = + + # magicant = inputs.nix-on-droid.lib.nixOnDroidConfiguration { + # pkgs = lib.swarselsystems.pkgsFor.aarch64-linux; + # modules = [ + # ./hosts/magicant + # ]; + # }; + + lib.swarselsystems.mkHalfHostConfigs (lib.swarselsystems.readHosts "android") "android" lib.swarselsystems.pkgsFor.aarch64-linux; - magicant = inputs.nix-on-droid.lib.nixOnDroidConfiguration { - pkgs = pkgsFor.aarch64-linux; - modules = [ - ./hosts/magicant - ]; - }; - }; topology = - forEachSystem (pkgs: import inputs.nix-topology { + lib.swarselsystems.forEachSystem (pkgs: import inputs.nix-topology { inherit pkgs; modules = [ # Your own file to define global topology. Works in principle like a nixos module but uses different options. diff --git a/hosts/android/magicant/default.nix b/hosts/android/magicant/default.nix new file mode 100644 index 0000000..4abd480 --- /dev/null +++ b/hosts/android/magicant/default.nix @@ -0,0 +1,44 @@ +{ pkgs, ... }: { + environment = { + packages = with pkgs; [ + vim + git + openssh + # toybox + dig + man + gnupg + curl + deadnix + statix + nixpgks-fmt + nvd + ]; + + etcBackupExtension = ".bak"; + extraOutputsToInstall = [ + "doc" + "info" + "devdoc" + ]; + motd = null; + }; + + android-integration = { + termux-open.enable = true; + xdg-open.enable = true; + termux-open-url.enable = true; + termux-reload-settings.enable = true; + termux-setup-storage.enable = true; + }; + + # Backup etc files instead of failing to activate generation if a file already exists in /etc + + # Read the changelog before changing this value + system.stateVersion = "23.05"; + + # Set up nix for flakes + nix.extraOptions = '' + experimental-features = nix-command flakes + ''; +} diff --git a/hosts/home-manager/default/default.nix b/hosts/home-manager/default/default.nix index 548b943..7d8d581 100644 --- a/hosts/home-manager/default/default.nix +++ b/hosts/home-manager/default/default.nix @@ -1,7 +1,7 @@ { self, inputs, outputs, config, ... }: { - imports = builtins.attrValues outputs.homeManagerModules; + imports = outputs.homeModules ++ outputs.mixedModules ++ (builtins.attrValues outputs.homeManagerModules); nixpkgs = { overlays = [ outputs.overlays.default ]; @@ -27,29 +27,6 @@ isLaptop = true; isNixos = false; wallpaper = self + /wallpaper/surfacewp.png; - temperatureHwmon = { - isAbsolutePath = true; - path = "/sys/devices/platform/thinkpad_hwmon/hwmon/"; - input-filename = "temp1_input"; - }; - monitors = { - main = { - name = "California Institute of Technology 0x1407 Unknown"; - mode = "1920x1080"; # TEMPLATE - scale = "1"; - position = "2560,0"; - workspace = "2:二"; - output = "eDP-1"; - }; - }; - inputs = { - "1:1:AT_Translated_Set_2_keyboard" = { - xkb_layout = "us"; - xkb_options = "grp:win_space_toggle"; - xkb_variant = "altgr-intl"; - }; - }; - keybindings = { }; }; } diff --git a/hosts/home/default/default.nix b/hosts/home/default/default.nix new file mode 100644 index 0000000..548b943 --- /dev/null +++ b/hosts/home/default/default.nix @@ -0,0 +1,55 @@ +{ self, inputs, outputs, config, ... }: +{ + + imports = builtins.attrValues outputs.homeManagerModules; + + nixpkgs = { + overlays = [ outputs.overlays.default ]; + config = { + allowUnfree = true; + }; + }; + + services.xcape = { + enable = true; + mapExpression = { + Control_L = "Escape"; + }; + }; + + programs.zsh.initExtra = " + export GPG_TTY=\"$(tty)\" + export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket) + gpgconf --launch gpg-agent + "; + + swarselsystems = { + isLaptop = true; + isNixos = false; + wallpaper = self + /wallpaper/surfacewp.png; + temperatureHwmon = { + isAbsolutePath = true; + path = "/sys/devices/platform/thinkpad_hwmon/hwmon/"; + input-filename = "temp1_input"; + }; + monitors = { + main = { + name = "California Institute of Technology 0x1407 Unknown"; + mode = "1920x1080"; # TEMPLATE + scale = "1"; + position = "2560,0"; + workspace = "2:二"; + output = "eDP-1"; + }; + }; + inputs = { + "1:1:AT_Translated_Set_2_keyboard" = { + xkb_layout = "us"; + xkb_options = "grp:win_space_toggle"; + xkb_variant = "altgr-intl"; + }; + }; + keybindings = { }; + }; + +} diff --git a/index.html b/index.html index 9a5ddf9..8895fdf 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + SwarselSystems: NixOS + Emacs Configuration @@ -221,7 +221,7 @@
  • 3.7. darwinConfigurations
  • 3.8. homeConfigurations
  • 3.9. nixOnDroidConfigurations
  • -
  • 3.10. topologyConfigurations
  • +
  • 3.10. topologyConfigurations
  • 4. System @@ -245,12 +245,12 @@
  • -
  • 4.1.3. Utility hosts +
  • 4.1.3. Utility hosts
  • @@ -275,14 +275,14 @@
  • 4.2.1.14. update-checker
  • 4.2.1.15. github-notifications
  • 4.2.1.16. screenshare
  • -
  • 4.2.1.17. bootstrap
  • -
  • 4.2.1.18. swarsel-rebuild
  • -
  • 4.2.1.19. swarsel-install
  • -
  • 4.2.1.20. swarsel-postinstall
  • +
  • 4.2.1.17. swarsel-bootstrap
  • +
  • 4.2.1.18. swarsel-rebuild
  • +
  • 4.2.1.19. swarsel-install
  • +
  • 4.2.1.20. swarsel-postinstall
  • 4.2.1.21. t2ts
  • 4.2.1.22. ts2t
  • -
  • 4.2.1.23. vershell
  • -
  • 4.2.1.24. eontimer
  • +
  • 4.2.1.23. vershell
  • +
  • 4.2.1.24. eontimer
  • 4.2.2. Overlays (additions, overrides, nixpkgs-stable)
  • @@ -293,7 +293,7 @@
  • 4.2.3.1.1. Wallpaper
  • 4.2.3.1.2. Hardware
  • 4.2.3.1.3. Setup
  • -
  • 4.2.3.1.4. Server
  • +
  • 4.2.3.1.4. Server
  • 4.2.3.1.5. Input
  • @@ -370,7 +370,7 @@
  • 4.3.1.29. Podmam (distrobox)
  • 4.3.1.30. Handle lid switch correctly
  • 4.3.1.31. Low battery notification
  • -
  • 4.3.1.32. Lanzaboote
  • +
  • 4.3.1.32. Lanzaboote
  • 4.3.2. Server @@ -685,7 +685,7 @@

    -This file has 58511 words spanning 14914 lines and was last revised on 2024-12-28 16:43:06 +0100. +This file has 58383 words spanning 14864 lines and was last revised on 2024-12-28 18:15:25 +0100.

    @@ -738,7 +738,7 @@ This section defines my Emacs configuration. For a while, I considered to use ry

    -My emacs is built using the emacs-overlay nix flake, which builds a bleeding edge emacs on wayland (pgtk) with utilities like treesitter support. By executing the below source block, the current build setting can be updated at any time, and you can see my most up-to-date build options (last updated: 2024-12-28 16:43:06 +0100) +My emacs is built using the emacs-overlay nix flake, which builds a bleeding edge emacs on wayland (pgtk) with utilities like treesitter support. By executing the below source block, the current build setting can be updated at any time, and you can see my most up-to-date build options (last updated: 2024-12-28 18:15:25 +0100)

  • @@ -1552,38 +1552,8 @@ In outputs = inputs@ [...], the inputs@ makes it so th let inherit (self) outputs; - lib = nixpkgs.lib // home-manager.lib; + lib = (nixpkgs.lib // home-manager.lib).extend (_: _: { swarselsystems = import ./lib { inherit self lib inputs outputs systems; }; }); - pkgsFor = lib.genAttrs (import systems) ( - system: - import nixpkgs { - inherit system; - config.allowUnfree = true; - } - ); - forEachSystem = f: lib.genAttrs (import systems) (system: f pkgsFor.${system}); - forAllSystems = lib.genAttrs [ - "x86_64-linux" - "aarch64-linux" - "x86_64-darwin" - "aarch64-darwin" - ]; - mkFullHost = host: isNixos: { - ${host} = - let - func = if isNixos then lib.nixosSystem else inputs.nix-darwin.lib.darwinSystem; - systemFunc = func; - in - systemFunc { - specialArgs = { - inherit inputs outputs self; - lib = lib.extend (_: _: { swarselsystems = import ./lib { inherit lib; }; }); - }; - modules = [ ./hosts/${if isNixos then "nixos" else "darwin"}/${host} ]; - }; - }; - mkFullHostConfigs = hosts: isNixos: lib.foldl (acc: set: acc // set) { } (lib.map (host: mkFullHost host isNixos) hosts); - readHosts = folder: lib.attrNames (builtins.readDir ./hosts/${folder}); # NixOS modules that can only be used on NixOS systems nixModules = [ @@ -1609,13 +1579,6 @@ In outputs = inputs@ [...], the inputs@ makes it so th ./profiles/common/home ]; - # For adding things to _module.args (making arguments available globally) - # moduleArgs = [ - # { - # _module.args = { inherit self; }; - # } - # ]; - in { @@ -1626,31 +1589,22 @@ In outputs = inputs@ [...], the inputs@ makes it so th nixosModules = import ./modules/nixos; homeManagerModules = import ./modules/home; - packages = forEachSystem (pkgs: import ./pkgs { inherit pkgs; }); - apps = forAllSystems (system: { - default = self.apps.${system}.bootstrap; + packages = lib.swarselsystems.forEachSystem (pkgs: import ./pkgs { inherit lib; }); - bootstrap = { - type = "app"; - program = "${self.packages.${system}.bootstrap}/bin/bootstrap"; - }; - - install = { - type = "app"; - program = "${self.packages.${system}.swarsel-install}/bin/swarsel-install"; - }; - - postinstall = { - type = "app"; - program = "${self.packages.${system}.swarsel-postinstall}/bin/swarsel-postinstall"; - }; - - rebuild = { - type = "app"; - program = "${self.packages.${system}.swarsel-rebuild}/bin/swarsel-rebuild"; - }; + apps = lib.swarselsystems.forAllSystems (system: let + appNames = [ + "swarsel-bootstrap" + "swarsel-install" + "swarsel-rebuild" + "swarsel-postinstall" + ]; + appSet = lib.swarselsystems.mkApps system appNames self; + in { + inherit appSet; + default = appSet.bootstrap; }); - devShells = forAllSystems ( + + devShells = lib.swarselsystems.forAllSystems ( system: let pkgs = nixpkgs.legacyPackages.${system}; @@ -1673,24 +1627,24 @@ In outputs = inputs@ [...], the inputs@ makes it so th }; }); - formatter = forEachSystem (pkgs: pkgs.nixpkgs-fmt); - checks = forAllSystems ( + formatter = lib.swarselsystems.forEachSystem (pkgs: pkgs.nixpkgs-fmt); + checks = lib.swarselsystems.forAllSystems ( system: let pkgs = nixpkgs.legacyPackages.${system}; in import ./checks { inherit self inputs system pkgs; } ); - overlays = import ./overlays { inherit inputs; }; + overlays = import ./overlays { inherit pkgs; }; nixosConfigurations = - mkFullHostConfigs (readHosts "nixos") true; + lib.swarselsystems.mkFullHostConfigs (lib.swarselsystems.readHosts "nixos") true; homeConfigurations = { "swarsel@home-manager" = inputs.home-manager.lib.homeManagerConfiguration { - pkgs = pkgsFor.x86_64-linux; + pkgs = lib.swarselsystems.pkgsFor.x86_64-linux; extraSpecialArgs = { inherit inputs outputs; }; modules = homeModules ++ mixedModules ++ [ ./hosts/home-manager @@ -1700,12 +1654,12 @@ In outputs = inputs@ [...], the inputs@ makes it so th }; darwinConfigurations = - mkFullHostConfigs (readHosts "darwin") false; + lib.swarselsystems.mkFullHostConfigs (lib.swarselsystems.readHosts "darwin") false; nixOnDroidConfigurations = { magicant = inputs.nix-on-droid.lib.nixOnDroidConfiguration { - pkgs = pkgsFor.aarch64-linux; + pkgs = lib.swarselsystems.pkgsFor.aarch64-linux; modules = [ ./hosts/magicant ]; @@ -1715,7 +1669,7 @@ In outputs = inputs@ [...], the inputs@ makes it so th topology = - forEachSystem (pkgs: import inputs.nix-topology { + lib.swarselsystems.forEachSystem (pkgs: import inputs.nix-topology { inherit pkgs; modules = [ # Your own file to define global topology. Works in principle like a nixos module but uses different options. @@ -1989,38 +1943,8 @@ The interesting part is in the start:
     inherit (self) outputs;
    -lib = nixpkgs.lib // home-manager.lib;
    +lib = (nixpkgs.lib // home-manager.lib).extend  (_: _: { swarselsystems = import ./lib { inherit self lib inputs outputs systems; }; });
     
    -pkgsFor = lib.genAttrs (import systems) (
    -  system:
    -  import nixpkgs {
    -    inherit system;
    -    config.allowUnfree = true;
    -  }
    -);
    -forEachSystem = f: lib.genAttrs (import systems) (system: f pkgsFor.${system});
    -forAllSystems = lib.genAttrs [
    -  "x86_64-linux"
    -  "aarch64-linux"
    -  "x86_64-darwin"
    -  "aarch64-darwin"
    -];
    -mkFullHost = host: isNixos: {
    -  ${host} =
    -    let
    -      func = if isNixos then lib.nixosSystem else inputs.nix-darwin.lib.darwinSystem;
    -      systemFunc = func;
    -    in
    -    systemFunc {
    -      specialArgs = {
    -        inherit inputs outputs self;
    -        lib = lib.extend (_: _: { swarselsystems = import ./lib { inherit lib; }; });
    -      };
    -      modules = [ ./hosts/${if isNixos then "nixos" else "darwin"}/${host} ];
    -    };
    -};
    -mkFullHostConfigs = hosts: isNixos: lib.foldl (acc: set: acc // set) { } (lib.map (host: mkFullHost host isNixos) hosts);
    -readHosts = folder: lib.attrNames (builtins.readDir ./hosts/${folder});
     
     # NixOS modules that can only be used on NixOS systems
     nixModules = [
    @@ -2046,13 +1970,6 @@ mixedModules = [
       ./profiles/common/home
     ];
     
    -# For adding things to _module.args (making arguments available globally)
    -# moduleArgs = [
    -#   {
    -#     _module.args = { inherit self; };
    -#   }
    -# ];
    -
     
    @@ -2094,31 +2011,22 @@ inherit nixModules; nixosModules = import ./modules/nixos; homeManagerModules = import ./modules/home; -packages = forEachSystem (pkgs: import ./pkgs { inherit pkgs; }); -apps = forAllSystems (system: { - default = self.apps.${system}.bootstrap; +packages = lib.swarselsystems.forEachSystem (pkgs: import ./pkgs { inherit lib; }); - bootstrap = { - type = "app"; - program = "${self.packages.${system}.bootstrap}/bin/bootstrap"; - }; - - install = { - type = "app"; - program = "${self.packages.${system}.swarsel-install}/bin/swarsel-install"; - }; - - postinstall = { - type = "app"; - program = "${self.packages.${system}.swarsel-postinstall}/bin/swarsel-postinstall"; - }; - - rebuild = { - type = "app"; - program = "${self.packages.${system}.swarsel-rebuild}/bin/swarsel-rebuild"; - }; +apps = lib.swarselsystems.forAllSystems (system: let + appNames = [ + "swarsel-bootstrap" + "swarsel-install" + "swarsel-rebuild" + "swarsel-postinstall" + ]; + appSet = lib.swarselsystems.mkApps system appNames self; +in { + inherit appSet; + default = appSet.bootstrap; }); -devShells = forAllSystems ( + +devShells = lib.swarselsystems.forAllSystems ( system: let pkgs = nixpkgs.legacyPackages.${system}; @@ -2141,15 +2049,15 @@ devShells = forAllSystems ( }; }); -formatter = forEachSystem (pkgs: pkgs.nixpkgs-fmt); -checks = forAllSystems ( +formatter = lib.swarselsystems.forEachSystem (pkgs: pkgs.nixpkgs-fmt); +checks = lib.swarselsystems.forAllSystems ( system: let pkgs = nixpkgs.legacyPackages.${system}; in import ./checks { inherit self inputs system pkgs; } ); -overlays = import ./overlays { inherit inputs; }; +overlays = import ./overlays { inherit pkgs; }; @@ -2169,7 +2077,7 @@ Note: The preceding nixosConfigurations is found in -
    mkFullHostConfigs (readHosts "nixos") true;
    +
    lib.swarselsystems.mkFullHostConfigs (lib.swarselsystems.readHosts "nixos") true;
     
    @@ -2187,7 +2095,7 @@ Note: The preceding darwinConfigurations is found in
    -
    mkFullHostConfigs (readHosts "darwin") false;
    +
    lib.swarselsystems.mkFullHostConfigs (lib.swarselsystems.readHosts "darwin") false;
     
    @@ -2202,7 +2110,7 @@ In contrast, this defines home-manager systems, which I only have one of, that s
     "swarsel@home-manager" = inputs.home-manager.lib.homeManagerConfiguration {
    - pkgs = pkgsFor.x86_64-linux;
    + pkgs = lib.swarselsystems.pkgsFor.x86_64-linux;
      extraSpecialArgs = { inherit inputs outputs; };
       modules = homeModules ++ mixedModules ++ [
         ./hosts/home-manager
    @@ -2223,7 +2131,7 @@ Nix on Android also demands an own flake output, which is provided here.
     
     magicant = inputs.nix-on-droid.lib.nixOnDroidConfiguration {
    - pkgs = pkgsFor.aarch64-linux;
    + pkgs = lib.swarselsystems.pkgsFor.aarch64-linux;
       modules = [
         ./hosts/magicant
       ];
    @@ -2233,12 +2141,12 @@ magicant = inputs.nix-on-droid.lib.nixOnDroidConfiguration {
     
    -
    -

    3.10. topologyConfigurations

    +
    +

    3.10. topologyConfigurations

    -forEachSystem (pkgs: import inputs.nix-topology {
    +lib.swarselsystems.forEachSystem (pkgs: import inputs.nix-topology {
       inherit pkgs;
       modules = [
         # Your own file to define global topology. Works in principle like a nixos module but uses different options.
    @@ -2826,12 +2734,12 @@ in
     
    -
    -

    4.1.3. Utility hosts

    +
    +

    4.1.3. Utility hosts

    -
    -
    4.1.3.1. Toto (Physical/VM)
    +
    +
    4.1.3.1. Toto (Physical/VM)

    This is a slim setup for developing base configuration. @@ -3156,8 +3064,8 @@ This is the "reference implementation" of a setup that runs without NixOS, only

    -
    -
    4.1.3.4. ChaosTheatre (Demo Physical/VM)
    +
    +
    4.1.3.4. ChaosTheatre (Demo Physical/VM)

    This is just a demo host. It applies all the configuration found in the common parts of the flake, but disables all secrets-related features (as they would not work without the proper SSH keys). @@ -3265,7 +3173,7 @@ Note: The structure of generating the packages was changed in commit 2cf03

    -
    { pkgs, ... }:
    +
    { lib, ... }:
     let
       packageNames = [
         "pass-fuzzel"
    @@ -3283,7 +3191,7 @@ let
         "update-checker"
         "github-notifications"
         "screenshare"
    -    "bootstrap"
    +    "swarsel-bootstrap"
         "swarsel-rebuild"
         "swarsel-install"
         "swarsel-postinstall"
    @@ -3292,12 +3200,8 @@ let
         "vershell"
         "eontimer"
       ];
    -  mkPackages = names: builtins.listToAttrs (map (name: {
    -    inherit name;
    -    value = pkgs.callPackage ./${name} { };
    -  }) names);
       in
    -  mkPackages packageNames
    + lib.swarselsystems.mkPackages packageNames
     
     
     
    @@ -3937,7 +3841,7 @@ writeShellApplication {
    -
    4.2.1.17. bootstrap
    +
    4.2.1.17. swarsel-bootstrap

    This program sets up a new NixOS host remotely. It also takes care of secret management on the new host. @@ -4291,16 +4195,16 @@ fi

    { writeShellApplication, openssh }:
     
     writeShellApplication {
    -  name = "bootstrap";
    +  name = "swarsel-bootstrap";
       runtimeInputs = [ openssh ];
    -  text = builtins.readFile ../../scripts/bootstrap.sh;
    +  text = builtins.readFile ../../scripts/swarsel-bootstrap.sh;
     }
     
    -
    -
    4.2.1.18. swarsel-rebuild
    +
    +
    4.2.1.18. swarsel-rebuild

    This program builds a configuration locally. @@ -4411,8 +4315,8 @@ writeShellApplication {

    -
    -
    4.2.1.19. swarsel-install
    +
    +
    4.2.1.19. swarsel-install

    This program sets up a new NixOS host locally. @@ -4599,8 +4503,8 @@ writeShellApplication {

    -
    -
    4.2.1.20. swarsel-postinstall
    +
    +
    4.2.1.20. swarsel-postinstall

    This program sets up a new NixOS host locally. @@ -4743,8 +4647,8 @@ writeShellApplication {

    -
    -
    4.2.1.23. vershell
    +
    +
    4.2.1.23. vershell

    This script allows for quick git branch switching. @@ -4765,8 +4669,8 @@ writeShellApplication {

    -
    -
    4.2.1.24. eontimer
    +
    +
    4.2.1.24. eontimer

    This script allows for quick git branch switching. @@ -4840,10 +4744,10 @@ When adding a new entry here, do not forget to add it in the default output of t

    -
    { inputs, ... }:
    +
    { inputs, lib, ... }:
     
     let
    -  additions = final: _prev: import ../pkgs { pkgs = final; };
    +  additions = final: _prev: import ../pkgs { pkgs = final; inherit lib };
       modifications = _: _prev: {
         vesktop = _prev.vesktop.override {
           withSystemVencord = true;
    @@ -5045,8 +4949,8 @@ I usually use mutableUsers = false in my NixOS configuration. Howev
     
    -
    -
    4.2.3.1.4. Server
    +
    +
    4.2.3.1.4. Server
    { lib, ... }:
    @@ -7432,8 +7336,8 @@ Since I hide the waybar completely during normal operation, I run the risk of no
     
    -
    -
    4.3.1.32. Lanzaboote
    +
    +
    4.3.1.32. Lanzaboote

    This dynamically uses systemd boot or Lanzaboote depending on `config.swarselsystems.initialSetup` and `config.swarselsystems.isSecureBoot`. @@ -9964,7 +9868,7 @@ This is just a separate container for derivations defined in

    diff --git a/lib/default.nix b/lib/default.nix index ed90255..639af2e 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,8 +1,90 @@ -{ lib, ... }: +{ self, lib, systems, inputs, outputs, ... }: { mkIfElseList = p: yes: no: lib.mkMerge [ (lib.mkIf p yes) (lib.mkIf (!p) no) ]; + mkIfElse = p: yes: no: if p then yes else no; + + forAllSystems = lib.genAttrs [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + + pkgsFor = lib.genAttrs (import systems) ( + system: + import inputs.nixpkgs { + inherit system; + config.allowUnfree = true; + } + ); + + forEachSystem = f: lib.genAttrs (import systems) (system: f lib.swarselsystems.pkgsFor.${system}); + + mkFullHost = host: type: { + ${host} = + let + systemFunc = if (type == "nixos") then lib.nixosSystem else inputs.nix-darwin.lib.darwinSystem; + in + systemFunc { + specialArgs = { inherit inputs outputs lib self; }; + modules = [ "${self}/hosts/${type}/${host}" ]; + }; + }; + + mkHalfHost = host: type: pkgs: { + ${host} = + let + systemFunc = if (type == "home") then inputs.home-manager.lib.homeManagerConfiguration else inputs.nix-on-droid.lib.nixOnDroidConfiguration; + in + systemFunc { + inherit pkgs; + extraSpecialArgs = { inherit inputs outputs; }; + modules = [ "${self}/hosts/${type}/${host}" ]; + }; + }; + + mkFullHostConfigs = hosts: type: lib.foldl (acc: set: acc // set) { } (lib.map (host: lib.swarselsystems.mkFullHost host type) hosts); + mkHalfHostConfigs = hosts: type: pkgs: lib.foldl (acc: set: acc // set) { } (lib.map (host: lib.swarselsystems.mkFullHost host type pkgs) hosts); + + readHosts = type: lib.attrNames (builtins.readDir "${self}/hosts/${type}"); + + mkApps = system: names: self: builtins.listToAttrs (map + (name: { + inherit name; + value = { + type = "app"; + program = "${self.packages.${system}.${name}}/bin/${name}"; + }; + }) + names); + + mkPackages = names: pkgs: builtins.listToAttrs (map + (name: { + inherit name; + value = pkgs.callPackage "${self}/pkgs/${name}" { }; + }) + names); + + + mkModules = names: type: builtins.listToAttrs (map + (name: { + inherit name; + value = import "${self}/modules/${type}/${name}.nix"; + }) + names); + + eachMonitor = _: monitor: { + inherit (monitor) name; + value = builtins.removeAttrs monitor [ "workspace" "name" "output" ]; + }; + + eachOutput = _: monitor: { + inherit (monitor) name; + value = builtins.removeAttrs monitor [ "mode" "name" "scale" "transform" "position" ]; + }; + } diff --git a/modules/home/default.nix b/modules/home/default.nix index 321bb0a..816bc25 100644 --- a/modules/home/default.nix +++ b/modules/home/default.nix @@ -1,3 +1,4 @@ +{ lib, ... }: let moduleNames = [ "laptop" @@ -12,13 +13,5 @@ let "filesystem" "firefox" ]; - - mkImports = names: builtins.listToAttrs (map - (name: { - inherit name; - value = import ./${name}.nix; - }) - names); - in -mkImports moduleNames +lib.swarselsystems.mkModules moduleNames "home" diff --git a/modules/home/filesystem.nix b/modules/home/filesystem.nix index 4fedd44..2ad2736 100644 --- a/modules/home/filesystem.nix +++ b/modules/home/filesystem.nix @@ -1,5 +1,4 @@ { lib, ... }: - { options.swarselsystems.isBtrfs = lib.mkEnableOption "use btrfs filesystem"; } diff --git a/modules/home/hardware.nix b/modules/home/hardware.nix index 137195c..2456790 100644 --- a/modules/home/hardware.nix +++ b/modules/home/hardware.nix @@ -1,5 +1,4 @@ { lib, ... }: - { options.swarselsystems.cpuCount = lib.mkOption { type = lib.types.int; diff --git a/modules/home/input.nix b/modules/home/input.nix index f8ad863..3e2db8e 100644 --- a/modules/home/input.nix +++ b/modules/home/input.nix @@ -1,14 +1,11 @@ { lib, config, ... }: -let - inherit (lib) mkOption types; -in { - options.swarselsystems.inputs = mkOption { - type = types.attrsOf (types.attrsOf types.str); + options.swarselsystems.inputs = lib.mkOption { + type = lib.types.attrsOf (lib.types.attrsOf lib.types.str); default = { }; }; - options.swarselsystems.kyria = mkOption { - type = types.attrsOf (types.attrsOf types.str); + options.swarselsystems.kyria = lib.mkOption { + type = lib.types.attrsOf (lib.types.attrsOf lib.types.str); default = { "36125:53060:splitkb.com_splitkb.com_Kyria_rev3" = { xkb_layout = "us"; @@ -20,21 +17,21 @@ in }; }; }; - options.swarselsystems.touchpad = mkOption { - type = types.attrsOf (types.attrsOf types.str); + options.swarselsystems.touchpad = lib.mkOption { + type = lib.types.attrsOf (lib.types.attrsOf lib.types.str); default = { }; }; - options.swarselsystems.standardinputs = mkOption { - type = types.attrsOf (types.attrsOf types.str); + options.swarselsystems.standardinputs = lib.mkOption { + type = lib.types.attrsOf (lib.types.attrsOf lib.types.str); default = lib.recursiveUpdate (lib.recursiveUpdate config.swarselsystems.touchpad config.swarselsystems.kyria) config.swarselsystems.inputs; internal = true; }; - options.swarselsystems.keybindings = mkOption { - type = types.attrsOf types.str; + options.swarselsystems.keybindings = lib.mkOption { + type = lib.types.attrsOf lib.types.str; default = { }; }; - options.swarselsystems.shellAliases = mkOption { - type = types.attrsOf types.str; + options.swarselsystems.shellAliases = lib.mkOption { + type = lib.types.attrsOf lib.types.str; default = { }; }; } diff --git a/modules/home/monitors.nix b/modules/home/monitors.nix index 232888c..c2ca92e 100644 --- a/modules/home/monitors.nix +++ b/modules/home/monitors.nix @@ -1,22 +1,19 @@ { lib, ... }: -let - inherit (lib) mkOption types; -in { - options.swarselsystems.monitors = mkOption { - type = types.attrsOf (types.attrsOf types.str); + options.swarselsystems.monitors = lib.mkOption { + type = lib.types.attrsOf (lib.types.attrsOf lib.types.str); default = { }; }; - options.swarselsystems.sharescreen = mkOption { - type = types.str; + options.swarselsystems.sharescreen = lib.mkOption { + type = lib.types.str; default = ""; }; - options.swarselsystems.lowResolution = mkOption { - type = types.str; + options.swarselsystems.lowResolution = lib.mkOption { + type = lib.types.str; default = ""; }; - options.swarselsystems.highResolution = mkOption { - type = types.str; + options.swarselsystems.highResolution = lib.mkOption { + type = lib.types.str; default = ""; }; } diff --git a/modules/home/nixos.nix b/modules/home/nixos.nix index ff9e33f..f7d2e9f 100644 --- a/modules/home/nixos.nix +++ b/modules/home/nixos.nix @@ -7,9 +7,7 @@ options.swarselsystems.isNixos = lib.mkEnableOption "nixos host"; options.swarselsystems.isPublic = lib.mkEnableOption "is a public machine (no secrets)"; config.swarselsystems.startup = lib.mkIf (!config.swarselsystems.isNixos) [ - { - command = "sleep 60 && nixGL nextcloud --background"; - } + { command = "sleep 60 && nixGL nextcloud --background"; } { command = "sleep 60 && nixGL vesktop --start-minimized -enable-features=UseOzonePlatform -ozone-platform=wayland"; } { command = "sleep 60 && nixGL syncthingtray --wait"; } { command = "sleep 60 && ANKI_WAYLAND=1 nixGL anki"; } @@ -17,6 +15,7 @@ { command = "sleep 60 && OBSIDIAN_USE_WAYLAND=1 nixGL obsidian -enable-features=UseOzonePlatform -ozone-platform=wayland"; } { command = "sleep 60 && element-desktop --hidden -enable-features=UseOzonePlatform -ozone-platform=wayland --disable-gpu-driver-bug-workarounds"; } ]; + options.swarselsystems.swayfxConfig = lib.mkOption { type = lib.types.str; default = " diff --git a/modules/home/startup.nix b/modules/home/startup.nix index 3bebcb9..fcda553 100644 --- a/modules/home/startup.nix +++ b/modules/home/startup.nix @@ -1,11 +1,7 @@ { lib, ... }: -let - inherit (lib) mkOption types; -in { - - options.swarselsystems.startup = mkOption { - type = types.listOf (types.attrsOf types.str); + options.swarselsystems.startup = lib.mkOption { + type = lib.types.listOf (lib.types.attrsOf lib.types.str); default = [ { command = "nextcloud --background"; } { command = "vesktop --start-minimized --enable-speech-dispatcher --ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime"; } diff --git a/modules/home/wallpaper.nix b/modules/home/wallpaper.nix index 2f44756..99e4c11 100644 --- a/modules/home/wallpaper.nix +++ b/modules/home/wallpaper.nix @@ -1,5 +1,4 @@ { lib, ... }: - { options.swarselsystems.wallpaper = lib.mkOption { type = lib.types.path; diff --git a/modules/home/waybar.nix b/modules/home/waybar.nix index f4ae8f0..6c49ba8 100644 --- a/modules/home/waybar.nix +++ b/modules/home/waybar.nix @@ -1,5 +1,4 @@ { lib, config, ... }: - let generateIcons = n: lib.concatStringsSep " " (builtins.map (x: "{icon" + toString x + "}") (lib.range 0 (n - 1))); in diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index 43c3221..d0a2249 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -1,3 +1,4 @@ +{ lib, ... }: let moduleNames = [ "wallpaper" @@ -6,13 +7,5 @@ let "server" "input" ]; - - mkImports = names: builtins.listToAttrs (map - (name: { - inherit name; - value = import ./${name}.nix; - }) - names); - in -mkImports moduleNames +lib.swarselsystems.mkModules moduleNames "nixos" diff --git a/modules/nixos/input.nix b/modules/nixos/input.nix index d9bb208..6e2d058 100644 --- a/modules/nixos/input.nix +++ b/modules/nixos/input.nix @@ -1,10 +1,7 @@ { lib, ... }: -let - inherit (lib) mkOption types; -in { - options.swarselsystems.shellAliases = mkOption { - type = types.attrsOf types.str; + options.swarselsystems.shellAliases = lib.mkOption { + type = lib.types.attrsOf lib.types.str; default = { }; }; } diff --git a/overlays/default.nix b/overlays/default.nix index 80249bb..8a78b1b 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -1,21 +1,22 @@ -{ inputs, ... }: +{ self, inputs, lib, ... }: let - additions = final: _prev: import ../pkgs { pkgs = final; }; - modifications = _: _prev: { - vesktop = _prev.vesktop.override { + additions = final: _: import "${self}/pkgs" { pkgs = final; inherit lib; }; + + modifications = _: prev: { + vesktop = prev.vesktop.override { withSystemVencord = true; }; - firefox = _prev.firefox.override { + firefox = prev.firefox.override { nativeMessagingHosts = [ - _prev.tridactyl-native - _prev.browserpass - _prev.plasma5Packages.plasma-browser-integration + prev.tridactyl-native + prev.browserpass + prev.plasma5Packages.plasma-browser-integration ]; }; - retroarch = _prev.retroarch.withCores (cores: with cores; [ + retroarch = prev.retroarch.withCores (cores: with cores; [ snes9x # snes nestopia # nes dosbox # dos @@ -26,10 +27,6 @@ let dolphin # gc/wii ]); - # prismlauncher = _prev.prismlauncher.override { - # glfw = _prev.glfw-wayland-minecraft; - # }; - # #river = prev.river.overrideAttrs (oldAttrs: rec { # pname = "river"; # version = "git"; @@ -43,15 +40,15 @@ let # }); }; - nixpkgs-stable = final: _prev: { + nixpkgs-stable = final: _: { stable = import inputs.nixpkgs-stable { inherit (final) system; config.allowUnfree = true; }; }; - zjstatus = _: _prev: { - zjstatus = inputs.zjstatus.packages.${_prev.system}.default; + zjstatus = _: prev: { + zjstatus = inputs.zjstatus.packages.${prev.system}.default; }; in diff --git a/pkgs/default.nix b/pkgs/default.nix index 5491cf6..df56659 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ lib, pkgs, ... }: let packageNames = [ "pass-fuzzel" @@ -16,7 +16,7 @@ let "update-checker" "github-notifications" "screenshare" - "bootstrap" + "swarsel-bootstrap" "swarsel-rebuild" "swarsel-install" "swarsel-postinstall" @@ -25,11 +25,5 @@ let "vershell" "eontimer" ]; - mkPackages = names: builtins.listToAttrs (map - (name: { - inherit name; - value = pkgs.callPackage ./${name} { }; - }) - names); in -mkPackages packageNames +lib.swarselsystems.mkPackages packageNames pkgs diff --git a/pkgs/bootstrap/default.nix b/pkgs/swarsel-bootstrap/default.nix similarity index 50% rename from pkgs/bootstrap/default.nix rename to pkgs/swarsel-bootstrap/default.nix index 2f7062f..b4cc8de 100644 --- a/pkgs/bootstrap/default.nix +++ b/pkgs/swarsel-bootstrap/default.nix @@ -1,7 +1,7 @@ { writeShellApplication, openssh }: writeShellApplication { - name = "bootstrap"; + name = "swarsel-bootstrap"; runtimeInputs = [ openssh ]; - text = builtins.readFile ../../scripts/bootstrap.sh; + text = builtins.readFile ../../scripts/swarsel-bootstrap.sh; } diff --git a/profiles/common/home/custom-packages.nix b/profiles/common/home/custom-packages.nix index 2ba7c9f..843a7c1 100644 --- a/profiles/common/home/custom-packages.nix +++ b/profiles/common/home/custom-packages.nix @@ -22,7 +22,7 @@ vershell eontimer - bootstrap + swarsel-bootstrap (pkgs.writeScriptBin "project" '' #! ${pkgs.bash}/bin/bash diff --git a/profiles/common/home/sops.nix b/profiles/common/home/sops.nix index 259bc3e..6c475cb 100644 --- a/profiles/common/home/sops.nix +++ b/profiles/common/home/sops.nix @@ -1,14 +1,8 @@ { config, lib, ... }: -let - mkIfElse = p: yes: no: lib.mkMerge [ - (lib.mkIf p yes) - (lib.mkIf (!p) no) - ]; -in { sops = lib.mkIf (!config.swarselsystems.isPublic) { age.sshKeyPaths = [ "${config.home.homeDirectory}/.ssh/sops" "${config.home.homeDirectory}/.ssh/ssh_host_ed25519_key" ]; - defaultSopsFile = mkIfElse config.swarselsystems.isBtrfs "/persist/.dotfiles/secrets/general/secrets.yaml" "${config.home.homeDirectory}/.dotfiles/secrets/general/secrets.yaml"; + defaultSopsFile = lib.swarselsystems.mkIfElseList config.swarselsystems.isBtrfs "/persist/.dotfiles/secrets/general/secrets.yaml" "${config.home.homeDirectory}/.dotfiles/secrets/general/secrets.yaml"; validateSopsFiles = false; secrets = { diff --git a/profiles/common/home/sway.nix b/profiles/common/home/sway.nix index 8b76bce..2f5a73f 100644 --- a/profiles/common/home/sway.nix +++ b/profiles/common/home/sway.nix @@ -1,15 +1,7 @@ { config, lib, ... }: let inherit (config.swarselsystems) monitors; - eachMonitor = _name: monitor: { - inherit (monitor) name; - value = builtins.removeAttrs monitor [ "workspace" "name" "output" ]; - }; - eachOutput = _name: monitor: { - inherit (monitor) name; - value = builtins.removeAttrs monitor [ "mode" "name" "scale" "transform" "position" ]; - }; - workplaceSets = lib.mapAttrs' eachOutput monitors; + workplaceSets = lib.mapAttrs' lib.swarselsystems.eachOutput monitors; workplaceOutputs = map (key: lib.getAttr key workplaceSets) (lib.attrNames workplaceSets); in { @@ -135,7 +127,7 @@ in }; }; defaultWorkspace = "workspace 1:一"; - output = lib.mapAttrs' eachMonitor monitors; + output = lib.mapAttrs' lib.swarselsystems.eachMonitor monitors; input = config.swarselsystems.standardinputs; workspaceOutputAssign = workplaceOutputs; startup = config.swarselsystems.startup ++ [ diff --git a/profiles/common/nixos/impermanence.nix b/profiles/common/nixos/impermanence.nix index 2baff5b..d4b595a 100644 --- a/profiles/common/nixos/impermanence.nix +++ b/profiles/common/nixos/impermanence.nix @@ -1,9 +1,7 @@ { config, lib, ... }: let - mkIfElse = p: yes: no: if p then yes else no; - mapperTarget = mkIfElse config.swarselsystems.isCrypted "/dev/mapper/cryptroot" "/dev/disk/by-label/nixos"; + mapperTarget = lib.swarselsystems.mkIfElse config.swarselsystems.isCrypted "/dev/mapper/cryptroot" "/dev/disk/by-label/nixos"; in - { security.sudo.extraConfig = lib.mkIf config.swarselsystems.isImpermanence '' diff --git a/profiles/common/nixos/sops.nix b/profiles/common/nixos/sops.nix index dd69e1e..1bc9a17 100644 --- a/profiles/common/nixos/sops.nix +++ b/profiles/common/nixos/sops.nix @@ -1,15 +1,9 @@ { config, lib, ... }: -let - mkIfElse = p: yes: no: lib.mkMerge [ - (lib.mkIf p yes) - (lib.mkIf (!p) no) - ]; -in { sops = lib.mkIf (!config.swarselsystems.isPublic) { - age.sshKeyPaths = mkIfElse config.swarselsystems.isBtrfs [ "/persist/.ssh/sops" "/persist/.ssh/ssh_host_ed25519_key" ] [ "${config.users.users.swarsel.home}/.ssh/sops" "/etc/ssh/ssh_host_ed25519_key" ]; - defaultSopsFile = mkIfElse config.swarselsystems.isBtrfs "/persist/.dotfiles/secrets/general/secrets.yaml" "${config.users.users.swarsel.home}/.dotfiles/secrets/general/secrets.yaml"; + age.sshKeyPaths = lib.swarselsystems.mkIfElseList config.swarselsystems.isBtrfs [ "/persist/.ssh/sops" "/persist/.ssh/ssh_host_ed25519_key" ] [ "${config.users.users.swarsel.home}/.ssh/sops" "/etc/ssh/ssh_host_ed25519_key" ]; + defaultSopsFile = lib.swarselsystems.mkIfElseList config.swarselsystems.isBtrfs "/persist/.dotfiles/secrets/general/secrets.yaml" "${config.users.users.swarsel.home}/.dotfiles/secrets/general/secrets.yaml"; validateSopsFiles = false; diff --git a/scripts/bootstrap.sh b/scripts/swarsel-bootstrap.sh similarity index 100% rename from scripts/bootstrap.sh rename to scripts/swarsel-bootstrap.sh