refactor: lib, flake.nix

This commit is contained in:
Leon Schwarzäugl 2024-12-28 23:59:43 +01:00
parent a0f4384034
commit b71bb5794a
Signed by: swarsel
GPG key ID: 26A54C31F2A4FD84
27 changed files with 540 additions and 706 deletions

View file

@ -714,16 +714,16 @@ In =outputs = inputs@ [...]=, the =inputs@= makes it so that all inputs are auto
nixosConfigurations =
<<flakenixosconf>>
homeConfigurations = {
homeConfigurations =
<<flakehomeconf>>
};
darwinConfigurations =
<<flakedarwinconf>>
nixOnDroidConfigurations = {
nixOnDroidConfigurations =
<<flakedroidconf>>
};
topology =
<<topologyconf>>
@ -966,38 +966,8 @@ The interesting part is in the start:
#+begin_src nix :tangle no :noweb-ref flakelet
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 = [
@ -1023,13 +993,6 @@ The interesting part is in the start:
./profiles/common/home
];
# For adding things to _module.args (making arguments available globally)
# moduleArgs = [
# {
# _module.args = { inherit self; };
# }
# ];
#+end_src
** General (outputs)
:PROPERTIES:
@ -1053,39 +1016,30 @@ 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;
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 (
system:
devShells = lib.swarselsystems.forAllSystems (system:
let
pkgs = nixpkgs.legacyPackages.${system};
checks = self.checks.${system};
@ -1095,27 +1049,28 @@ In this section I am creating some attributes that define general concepts of my
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; };
#+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 ++ [

157
flake.nix
View file

@ -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;
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 (
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.

View file

@ -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
'';
}

View file

@ -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 = { };
};
}

View file

@ -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 = { };
};
}

View file

@ -3,7 +3,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2024-12-28 Sa 16:43 -->
<!-- 2024-12-28 Sa 18:15 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>SwarselSystems: NixOS + Emacs Configuration</title>
@ -221,7 +221,7 @@
<li><a href="#h:f881aa05-a670-48dd-a57b-2916abdcb692">3.7. darwinConfigurations</a></li>
<li><a href="#h:f881aa05-a670-48dd-a57b-2916abdcb692">3.8. homeConfigurations</a></li>
<li><a href="#h:5f6ef553-59f9-4239-b6f3-63d33b57f335">3.9. nixOnDroidConfigurations</a></li>
<li><a href="#orgd28d2ce">3.10. topologyConfigurations</a></li>
<li><a href="#orgd058157">3.10. topologyConfigurations</a></li>
</ul>
</li>
<li><a href="#h:02cd20be-1ffa-4904-9d5a-da5a89ba1421">4. System</a>
@ -245,12 +245,12 @@
</li>
</ul>
</li>
<li><a href="#orgd491f98">4.1.3. Utility hosts</a>
<li><a href="#orgaaba600">4.1.3. Utility hosts</a>
<ul>
<li><a href="#org77e9aa9">4.1.3.1. Toto (Physical/VM)</a></li>
<li><a href="#org87a675b">4.1.3.1. Toto (Physical/VM)</a></li>
<li><a href="#h:8583371d-5d47-468b-84ba-210aad7e2c90">4.1.3.2. drugstore (ISO)</a></li>
<li><a href="#h:7056b9a0-f38b-4bca-b2ba-ab34e2d73493">4.1.3.3. Home-manager only (non-NixOS)</a></li>
<li><a href="#org2b0d997">4.1.3.4. ChaosTheatre (Demo Physical/VM)</a></li>
<li><a href="#org869d7a3">4.1.3.4. ChaosTheatre (Demo Physical/VM)</a></li>
</ul>
</li>
</ul>
@ -275,14 +275,14 @@
<li><a href="#h:4d864147-f9ef-46da-9b4f-4e7996a65157">4.2.1.14. update-checker</a></li>
<li><a href="#h:a9398c4e-4d3b-4942-b03c-192f9c0517e5">4.2.1.15. github-notifications</a></li>
<li><a href="#h:960e539c-2a5a-4e21-b3d4-bcdfc8be8fda">4.2.1.16. screenshare</a></li>
<li><a href="#h:74db57ae-0bb9-4257-84be-eddbc85130dd">4.2.1.17. bootstrap</a></li>
<li><a href="#orgd873577">4.2.1.18. swarsel-rebuild</a></li>
<li><a href="#orgd81a8e9">4.2.1.19. swarsel-install</a></li>
<li><a href="#org829f5bd">4.2.1.20. swarsel-postinstall</a></li>
<li><a href="#h:74db57ae-0bb9-4257-84be-eddbc85130dd">4.2.1.17. swarsel-bootstrap</a></li>
<li><a href="#org7469bc3">4.2.1.18. swarsel-rebuild</a></li>
<li><a href="#orge755727">4.2.1.19. swarsel-install</a></li>
<li><a href="#org0dbac39">4.2.1.20. swarsel-postinstall</a></li>
<li><a href="#h:5ad99997-e54c-4f0b-9ab7-15f76b1e16e1">4.2.1.21. t2ts</a></li>
<li><a href="#h:5ad99997-e54c-4f0b-9ab7-15f76b1e16e1">4.2.1.22. ts2t</a></li>
<li><a href="#orgcf9834d">4.2.1.23. vershell</a></li>
<li><a href="#org33d3655">4.2.1.24. eontimer</a></li>
<li><a href="#org3d80a50">4.2.1.23. vershell</a></li>
<li><a href="#org83d7b29">4.2.1.24. eontimer</a></li>
</ul>
</li>
<li><a href="#h:5e3e21e0-57af-4dad-b32f-6400af9b7aab">4.2.2. Overlays (additions, overrides, nixpkgs-stable)</a></li>
@ -293,7 +293,7 @@
<li><a href="#h:bd7517c6-0e0a-4063-bc81-e62cd24e7170">4.2.3.1.1. Wallpaper</a></li>
<li><a href="#h:c6a138ff-f07f-4cae-95b9-b6daa2b11463">4.2.3.1.2. Hardware</a></li>
<li><a href="#h:f4f22166-e345-43e6-b15f-b7f5bb886554">4.2.3.1.3. Setup</a></li>
<li><a href="#orgba39c14">4.2.3.1.4. Server</a></li>
<li><a href="#org3ba7862">4.2.3.1.4. Server</a></li>
<li><a href="#h:45188d3c-9910-480b-beec-d5fd713b05fb">4.2.3.1.5. Input</a></li>
</ul>
</li>
@ -370,7 +370,7 @@
<li><a href="#h:1bef3914-a258-4585-b232-e0fbe9e7a9b5">4.3.1.29. Podmam (distrobox)</a></li>
<li><a href="#h:a5a0d84e-c7b3-4164-a4c7-2e2d8ada69cd">4.3.1.30. Handle lid switch correctly</a></li>
<li><a href="#h:adf894d7-b3c6-4b8b-b13f-c28b3a5e1e17">4.3.1.31. Low battery notification</a></li>
<li><a href="#orgf0c4047">4.3.1.32. Lanzaboote</a></li>
<li><a href="#org9f79b09">4.3.1.32. Lanzaboote</a></li>
</ul>
</li>
<li><a href="#h:e492c24a-83a0-4bcb-a084-706f49318651">4.3.2. Server</a>
@ -685,7 +685,7 @@
</div>
</div>
<p>
<b>This file has 58511 words spanning 14914 lines and was last revised on 2024-12-28 16:43:06 +0100.</b>
<b>This file has 58383 words spanning 14864 lines and was last revised on 2024-12-28 18:15:25 +0100.</b>
</p>
<p>
@ -738,7 +738,7 @@ This section defines my Emacs configuration. For a while, I considered to use ry
</p>
<p>
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)
</p></li>
</ul>
@ -1552,38 +1552,8 @@ In <code>outputs = inputs@ [...]</code>, the <code>inputs@</code> 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 <code>outputs = inputs@ [...]</code>, the <code>inputs@</code> 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 <code>outputs = inputs@ [...]</code>, the <code>inputs@</code> 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 <code>outputs = inputs@ [...]</code>, the <code>inputs@</code> 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 <code>outputs = inputs@ [...]</code>, the <code>inputs@</code> 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 <code>outputs = inputs@ [...]</code>, the <code>inputs@</code> 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:
<div class="org-src-container">
<pre class="src src-nix">
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; };
# }
# ];
</pre>
</div>
</div>
@ -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; };
</pre>
</div>
@ -2169,7 +2077,7 @@ Note: The preceding <code>nixosConfigurations</code> is found in <a href="#h:aee
<div class="org-src-container">
<pre class="src src-nix">mkFullHostConfigs (readHosts "nixos") true;
<pre class="src src-nix">lib.swarselsystems.mkFullHostConfigs (lib.swarselsystems.readHosts "nixos") true;
</pre>
</div>
</div>
@ -2187,7 +2095,7 @@ Note: The preceding <code>darwinConfigurations</code> is found in <a href="#h:ae
</p>
<div class="org-src-container">
<pre class="src src-nix">mkFullHostConfigs (readHosts "darwin") false;
<pre class="src src-nix">lib.swarselsystems.mkFullHostConfigs (lib.swarselsystems.readHosts "darwin") false;
</pre>
</div>
</div>
@ -2202,7 +2110,7 @@ In contrast, this defines home-manager systems, which I only have one of, that s
<div class="org-src-container">
<pre class="src src-nix">
"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.
<div class="org-src-container">
<pre class="src src-nix">
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 {
</div>
</div>
</div>
<div id="outline-container-orgd28d2ce" class="outline-3">
<h3 id="orgd28d2ce"><span class="section-number-3">3.10.</span> topologyConfigurations</h3>
<div id="outline-container-orgd058157" class="outline-3">
<h3 id="orgd058157"><span class="section-number-3">3.10.</span> topologyConfigurations</h3>
<div class="outline-text-3" id="text-3-10">
<div class="org-src-container">
<pre class="src src-nix">
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
</div>
</div>
</div>
<div id="outline-container-orgd491f98" class="outline-4">
<h4 id="orgd491f98"><span class="section-number-4">4.1.3.</span> Utility hosts</h4>
<div id="outline-container-orgaaba600" class="outline-4">
<h4 id="orgaaba600"><span class="section-number-4">4.1.3.</span> Utility hosts</h4>
<div class="outline-text-4" id="text-4-1-3">
</div>
<div id="outline-container-org77e9aa9" class="outline-5">
<h5 id="org77e9aa9"><span class="section-number-5">4.1.3.1.</span> Toto (Physical/VM)</h5>
<div id="outline-container-org87a675b" class="outline-5">
<h5 id="org87a675b"><span class="section-number-5">4.1.3.1.</span> Toto (Physical/VM)</h5>
<div class="outline-text-5" id="text-4-1-3-1">
<p>
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
</div>
</div>
</div>
<div id="outline-container-org2b0d997" class="outline-5">
<h5 id="org2b0d997"><span class="section-number-5">4.1.3.4.</span> ChaosTheatre (Demo Physical/VM)</h5>
<div id="outline-container-org869d7a3" class="outline-5">
<h5 id="org869d7a3"><span class="section-number-5">4.1.3.4.</span> ChaosTheatre (Demo Physical/VM)</h5>
<div class="outline-text-5" id="text-4-1-3-4">
<p>
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 <code>2cf03
</p>
<div class="org-src-container">
<pre class="src src-nix">{ pkgs, ... }:
<pre class="src src-nix">{ 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
</pre>
@ -3937,7 +3841,7 @@ writeShellApplication {
</div>
</div>
<div id="outline-container-h:74db57ae-0bb9-4257-84be-eddbc85130dd" class="outline-5">
<h5 id="h:74db57ae-0bb9-4257-84be-eddbc85130dd"><span class="section-number-5">4.2.1.17.</span> bootstrap</h5>
<h5 id="h:74db57ae-0bb9-4257-84be-eddbc85130dd"><span class="section-number-5">4.2.1.17.</span> swarsel-bootstrap</h5>
<div class="outline-text-5" id="text-h:74db57ae-0bb9-4257-84be-eddbc85130dd">
<p>
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
<pre class="src src-nix">{ writeShellApplication, openssh }:
writeShellApplication {
name = "bootstrap";
name = "swarsel-bootstrap";
runtimeInputs = [ openssh ];
text = builtins.readFile ../../scripts/bootstrap.sh;
text = builtins.readFile ../../scripts/swarsel-bootstrap.sh;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-orgd873577" class="outline-5">
<h5 id="orgd873577"><span class="section-number-5">4.2.1.18.</span> swarsel-rebuild</h5>
<div id="outline-container-org7469bc3" class="outline-5">
<h5 id="org7469bc3"><span class="section-number-5">4.2.1.18.</span> swarsel-rebuild</h5>
<div class="outline-text-5" id="text-4-2-1-18">
<p>
This program builds a configuration locally.
@ -4411,8 +4315,8 @@ writeShellApplication {
</div>
</div>
</div>
<div id="outline-container-orgd81a8e9" class="outline-5">
<h5 id="orgd81a8e9"><span class="section-number-5">4.2.1.19.</span> swarsel-install</h5>
<div id="outline-container-orge755727" class="outline-5">
<h5 id="orge755727"><span class="section-number-5">4.2.1.19.</span> swarsel-install</h5>
<div class="outline-text-5" id="text-4-2-1-19">
<p>
This program sets up a new NixOS host locally.
@ -4599,8 +4503,8 @@ writeShellApplication {
</div>
</div>
</div>
<div id="outline-container-org829f5bd" class="outline-5">
<h5 id="org829f5bd"><span class="section-number-5">4.2.1.20.</span> swarsel-postinstall</h5>
<div id="outline-container-org0dbac39" class="outline-5">
<h5 id="org0dbac39"><span class="section-number-5">4.2.1.20.</span> swarsel-postinstall</h5>
<div class="outline-text-5" id="text-4-2-1-20">
<p>
This program sets up a new NixOS host locally.
@ -4743,8 +4647,8 @@ writeShellApplication {
</div>
</div>
</div>
<div id="outline-container-orgcf9834d" class="outline-5">
<h5 id="orgcf9834d"><span class="section-number-5">4.2.1.23.</span> vershell</h5>
<div id="outline-container-org3d80a50" class="outline-5">
<h5 id="org3d80a50"><span class="section-number-5">4.2.1.23.</span> vershell</h5>
<div class="outline-text-5" id="text-4-2-1-23">
<p>
This script allows for quick git branch switching.
@ -4765,8 +4669,8 @@ writeShellApplication {
</div>
</div>
</div>
<div id="outline-container-org33d3655" class="outline-5">
<h5 id="org33d3655"><span class="section-number-5">4.2.1.24.</span> eontimer</h5>
<div id="outline-container-org83d7b29" class="outline-5">
<h5 id="org83d7b29"><span class="section-number-5">4.2.1.24.</span> eontimer</h5>
<div class="outline-text-5" id="text-4-2-1-24">
<p>
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
</p>
<div class="org-src-container">
<pre class="src src-nix">{ inputs, ... }:
<pre class="src src-nix">{ 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 <code>mutableUsers = false</code> in my NixOS configuration. Howev
</div>
</div>
</div>
<div id="outline-container-orgba39c14" class="outline-6">
<h6 id="orgba39c14"><span class="section-number-6">4.2.3.1.4.</span> Server</h6>
<div id="outline-container-org3ba7862" class="outline-6">
<h6 id="org3ba7862"><span class="section-number-6">4.2.3.1.4.</span> Server</h6>
<div class="outline-text-6" id="text-4-2-3-1-4">
<div class="org-src-container">
<pre class="src src-nix">{ lib, ... }:
@ -7432,8 +7336,8 @@ Since I hide the waybar completely during normal operation, I run the risk of no
</div>
</div>
</div>
<div id="outline-container-orgf0c4047" class="outline-5">
<h5 id="orgf0c4047"><span class="section-number-5">4.3.1.32.</span> Lanzaboote</h5>
<div id="outline-container-org9f79b09" class="outline-5">
<h5 id="org9f79b09"><span class="section-number-5">4.3.1.32.</span> Lanzaboote</h5>
<div class="outline-text-5" id="text-4-3-1-32">
<p>
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 <a href="#h:64a5cc1
vershell
eontimer
bootstrap
swarsel-bootstrap
(pkgs.writeScriptBin "project" ''
#! ${pkgs.bash}/bin/bash
@ -16917,7 +16821,7 @@ Prints a reasuring message to proove good faith."
</div>
<div id="postamble" class="status">
<p class="author">Author: Leon Schwarzäugl</p>
<p class="date">Created: 2024-12-28 Sa 16:43</p>
<p class="date">Created: 2024-12-28 Sa 18:15</p>
<p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
</body>

View file

@ -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" ];
};
}

View file

@ -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"

View file

@ -1,5 +1,4 @@
{ lib, ... }:
{
options.swarselsystems.isBtrfs = lib.mkEnableOption "use btrfs filesystem";
}

View file

@ -1,5 +1,4 @@
{ lib, ... }:
{
options.swarselsystems.cpuCount = lib.mkOption {
type = lib.types.int;

View file

@ -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 = { };
};
}

View file

@ -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 = "";
};
}

View file

@ -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 = "

View file

@ -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"; }

View file

@ -1,5 +1,4 @@
{ lib, ... }:
{
options.swarselsystems.wallpaper = lib.mkOption {
type = lib.types.path;

View file

@ -1,5 +1,4 @@
{ lib, config, ... }:
let
generateIcons = n: lib.concatStringsSep " " (builtins.map (x: "{icon" + toString x + "}") (lib.range 0 (n - 1)));
in

View file

@ -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"

View file

@ -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 = { };
};
}

View file

@ -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

View file

@ -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

View file

@ -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;
}

View file

@ -22,7 +22,7 @@
vershell
eontimer
bootstrap
swarsel-bootstrap
(pkgs.writeScriptBin "project" ''
#! ${pkgs.bash}/bin/bash

View file

@ -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 = {

View file

@ -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 ++ [

View file

@ -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 ''

View file

@ -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;