diff --git a/flake.lock b/flake.lock index b0acb12..bd911be 100644 --- a/flake.lock +++ b/flake.lock @@ -1050,11 +1050,11 @@ ] }, "locked": { - "lastModified": 1710888565, - "narHash": "sha256-s9Hi4RHhc6yut4EcYD50sZWRDKsugBJHSbON8KFwoTw=", + "lastModified": 1715381426, + "narHash": "sha256-wPuqrAQGdv3ISs74nJfGb+Yprm23U/rFpcHFFNWgM94=", "owner": "nix-community", "repo": "home-manager", - "rev": "f33900124c23c4eca5831b9b5eb32ea5894375ce", + "rev": "ab5542e9dbd13d0100f8baae2bc2d68af901f4b4", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index dc94f5a..8102084 100644 --- a/flake.nix +++ b/flake.nix @@ -79,6 +79,9 @@ outputs = { self, nixpkgs, home-manager, ... }@inputs: let + # Main username + pilot = "adrielus"; + # {{{ Common helpers inherit (self) outputs; forAllSystems = nixpkgs.lib.genAttrs [ @@ -127,14 +130,14 @@ # NixOS configuration entrypoint # Available through 'nixos-rebuild --flake .#... nixosConfigurations = - let nixos = { system, hostname, user }: nixpkgs.lib.nixosSystem { + let nixos = { system, hostname }: nixpkgs.lib.nixosSystem { inherit system; specialArgs = specialArgs system; modules = [ home-manager.nixosModules.home-manager { - home-manager.users.${user} = import ./home/${hostname}.nix; + home-manager.users.pilot = import ./home/${hostname}.nix; home-manager.extraSpecialArgs = specialArgs system // { inherit hostname; }; home-manager.useUserPackages = true; @@ -150,13 +153,11 @@ tethys = nixos { system = "x86_64-linux"; hostname = "tethys"; - user = "adrielus"; }; lapetus = nixos { system = "x86_64-linux"; hostname = "lapetus"; - user = "adrielus"; }; # Disabled because `flake check` complains about filesystems and bootloader @@ -165,7 +166,6 @@ # euporie = nixos { # system = "x86_64-linux"; # hostname = "euporie"; - # user = "guest"; # }; }; @@ -183,19 +183,7 @@ }; in { - nixd = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages."x86_64-linux"; - modules = [ - ({ lib, config, ... }: { - home = { - username = "adrielus"; - homeDirectory = "/home/${config.home.username}"; - stateVersion = "23.05"; - }; - }) - ]; - }; - "adrielus@tethys" = mkHomeConfig { + "${pilot}@tethys" = mkHomeConfig { system = "x86_64-linux"; hostname = "tethys"; }; @@ -203,7 +191,7 @@ system = "x86_64-linux"; hostname = "euporie"; }; - "adrielus@lapetus" = mkHomeConfig { + "${pilot}@lapetus" = mkHomeConfig { system = "x86_64-linux"; hostname = "lapetus"; }; diff --git a/home/features/cli/productivity/intray.nix b/home/features/cli/productivity/intray.nix index 7cb875c..b4ca876 100644 --- a/home/features/cli/productivity/intray.nix +++ b/home/features/cli/productivity/intray.nix @@ -3,8 +3,8 @@ programs.intray = { enable = true; - data-dir = "/persist/state/home/adrielus/intray"; - cache-dir = "/persist/local/cache/home/adrielus/intray"; + data-dir = "${config.satellite.persistence.at.state.home}/intray"; + cache-dir = "${config.satellite.persistence.at.cache.home}/intray"; config.sync = "AlwaysSync"; sync = { enable = true; diff --git a/home/features/cli/scripts/uptimes.sh b/home/features/cli/scripts/uptimes.sh index 4c6434b..20422c1 100755 --- a/home/features/cli/scripts/uptimes.sh +++ b/home/features/cli/scripts/uptimes.sh @@ -11,7 +11,7 @@ print_uptime() { # # For awk: # -F: splits the input by a string - ssh adrielus@$HOST uptime \ + ssh $USER@$HOST uptime \ | awk -F '(up |,)' '{print $2}' } diff --git a/home/features/cli/ssh.nix b/home/features/cli/ssh.nix index f702010..d5d3c08 100644 --- a/home/features/cli/ssh.nix +++ b/home/features/cli/ssh.nix @@ -1,8 +1,10 @@ -{ +{ config, ... }: { programs.ssh.enable = true; satellite.persistence.at.state.apps.ssh.directories = [ ".ssh" ]; # Makes it easy to copy ssh keys at install time without messing up permissions - systemd.user.tmpfiles.rules = [ "d /persist/state/home/adrielus/ssh/.ssh/etc/ssh" ]; + systemd.user.tmpfiles.rules = [ + "d ${config.satellite.persistence.at.state.home}/ssh/.ssh/etc/ssh" + ]; } diff --git a/home/features/desktop/discord/default.nix b/home/features/desktop/discord/default.nix index 2ab3033..6b2a73a 100644 --- a/home/features/desktop/discord/default.nix +++ b/home/features/desktop/discord/default.nix @@ -16,7 +16,6 @@ in { programs.discord = { enable = true; - enableOpenASAR = false; disableUpdateCheck = true; enableDevtools = true; }; diff --git a/home/features/desktop/firefox/default.nix b/home/features/desktop/firefox/default.nix index cbbf020..ae17241 100644 --- a/home/features/desktop/firefox/default.nix +++ b/home/features/desktop/firefox/default.nix @@ -48,7 +48,7 @@ in PasswordManagerEnabled = false; }; - profiles.adrielus = { + profiles.${config.home.username} = { # {{{ High level user settings # Unique user id id = 0; @@ -320,7 +320,7 @@ in # TODO: uncomment when using newer version # stylix.targets.firefox = { # enable = true; - # profileNames = [ "adrielus" "desmos" "monkey-type" "syncthing" ]; + # profileNames = [ config.home.username "desmos" "monkey-type" "syncthing" ]; # }; # {{{ Make firefox the default diff --git a/home/features/wayland/hyprland/hyprland.conf b/home/features/wayland/hyprland/hyprland.conf index 5e08334..915a275 100644 --- a/home/features/wayland/hyprland/hyprland.conf +++ b/home/features/wayland/hyprland/hyprland.conf @@ -89,7 +89,7 @@ bind = $mod, L, exec, loginctl lock-session # Lock screen bind = $mod, P, exec, anyrun bind = $mod, B, exec, wlsunset-toggle # Toggle blue light filter thingy bind = $mod, V, exec, wezterm start vimclip # Vim anywhere! -bind = $mod, W, exec, /home/adrielus/projects/form-filler/type.sh +bind = $mod, W, exec, ~/projects/form-filler/type.sh # Work with the special workspace bind = $mod, x, togglespecialworkspace, diff --git a/home/features/wayland/hyprland/hyprpaper.nix b/home/features/wayland/hyprland/hyprpaper.nix index 6e8ca8d..7de1334 100644 --- a/home/features/wayland/hyprland/hyprpaper.nix +++ b/home/features/wayland/hyprland/hyprpaper.nix @@ -1,14 +1,12 @@ -{ config, pkgs, lib, ... }: { - home.packages = [ pkgs.hyprpaper ]; +{ config, lib, ... }: { services.hyprpaper = { enable = true; - systemdTarget = "hyprland-session.target"; - - preload = [ config.stylix.image ]; - wallpapers = [{ inherit (config.stylix) image; }] ++ - lib.forEach config.satellite.monitors ({ name, ... }: { - monitor = name; - image = config.stylix.image; - }); + settings = { + preload = [ "${config.stylix.image}" ]; + wallpaper = [ ",${config.stylix.image}" ] ++ + lib.forEach config.satellite.monitors ({ name, ... }: + "${name},${config.stylix.image}" + ); + }; }; } diff --git a/home/global.nix b/home/global.nix index 656ca32..2f7d135 100644 --- a/home/global.nix +++ b/home/global.nix @@ -54,7 +54,7 @@ in # {{{ Set reasonable defaults for some settings home = { username = lib.mkDefault "adrielus"; - homeDirectory = lib.mkDefault "/home/${config.home.username}"; + homeDirectory = "/home/${config.home.username}"; stateVersion = lib.mkDefault "23.05"; }; # }}} @@ -68,9 +68,6 @@ in # By default the paths given by sops contain annoying %r sections sops.defaultSymlinkPath = "${config.home.homeDirectory}/.nix-sops"; - # Allow root to read persistent files from this user. - home.persistence."/persist/home/adrielus".allowOther = true; - # {{{ Ad-hoc stylix targets stylix.targets.xresources.enable = true; # }}} diff --git a/hosts/nixos/common/global/persistence.nix b/hosts/nixos/common/global/persistence.nix index 038e6d2..d5954df 100644 --- a/hosts/nixos/common/global/persistence.nix +++ b/hosts/nixos/common/global/persistence.nix @@ -19,10 +19,8 @@ # {{{ Create home directories systemd.tmpfiles.rules = let - users = lib.filter (v: v != null) [ - (config.users.users.adrielus or null) - (config.users.users.guest or null) - ]; + users = lib.filter (v: v != null && v.isNormalUser) + (lib.mapAttrsToList (_: u: u) config.users.users); mkHomePersistFor = location: lib.forEach users (user: "Q ${location}${user.home} ${user.homeMode} ${user.name} ${user.group} -"); diff --git a/hosts/nixos/common/optional/greetd.nix b/hosts/nixos/common/optional/greetd.nix index 9049813..81d04f8 100644 --- a/hosts/nixos/common/optional/greetd.nix +++ b/hosts/nixos/common/optional/greetd.nix @@ -12,7 +12,7 @@ --remember --asterisks ''; - user = "adrielus"; + user = config.users.users.pilot.name; }; }; }; diff --git a/hosts/nixos/common/optional/services/syncthing.nix b/hosts/nixos/common/optional/services/syncthing.nix index b4eb9ed..ddf2e0e 100644 --- a/hosts/nixos/common/optional/services/syncthing.nix +++ b/hosts/nixos/common/optional/services/syncthing.nix @@ -1,5 +1,8 @@ +{ config, ... }: let - user = "adrielus"; + # Using `config.users.users.pilot.name` causes an infinite recursion error + # due to the way the syncthing module is written + user = config.satellite.pilot.name; group = "syncthing"; dataDir = "/persist/data/syncthing"; in @@ -9,7 +12,7 @@ in enable = true; openDefaultPorts = true; - configDir = "/persist/state/home/adrielus/syncthing/.config/syncthing"; + configDir = "/persist/state/${config.users.users.pilot.home}/syncthing/.config/syncthing"; overrideDevices = true; overrideFolders = true; diff --git a/hosts/nixos/common/secrets.example.yaml b/hosts/nixos/common/secrets.example.yaml index 16fe548..b54ae4a 100644 --- a/hosts/nixos/common/secrets.example.yaml +++ b/hosts/nixos/common/secrets.example.yaml @@ -2,5 +2,5 @@ wireless: | TG_HOTSPOT_HOME_PASS=... ... -adrielus_password: ... +pilot_password: ... cloudflare_dns_api_token: ... diff --git a/hosts/nixos/common/secrets.yaml b/hosts/nixos/common/secrets.yaml index 80f8f66..903d901 100644 --- a/hosts/nixos/common/secrets.yaml +++ b/hosts/nixos/common/secrets.yaml @@ -1,5 +1,5 @@ wireless: ENC[AES256_GCM,data:Ib0PdBd2r/DPyE6Ah9NffT8Tw8c2y+seGFrE0e9GkyRaStdYMiiIlWCiaBO0u1HHaVV+2MQ33MnMdqyCGRlqGk45kl0GIwVR5iAiSYnobj/6wcse+kx/+5mzNOHXD1kJRGJBm5+SN9ntiGABNkQXJdn/Qoc/ukY1uaGe2nBeFKmGdD9JL7KfgdI5jYjQYyDbCL9JUszxkXNcplIRBAAy8JDaBVeo9HgI0QDIZToPKwuEeQoA9XzdimrjbCazlZy3ZvjAuoQXmrc1nIRHF5GabSRGTFTnTfcBeW2fGpUxmIhLyucn2DIQBXLm+RDdMLWoqcGbKiLVqKyUXck3ZZyoHMf2b9N52xMUwcS7,iv:ozkDwWmurWTD8TZHGvWL9Yh8cOrP1PzSBkz+1bBZybo=,tag:iGPjRaOoGRcOWJMweTL2yA==,type:str] -adrielus_password: ENC[AES256_GCM,data:lREgbcKwzAJQ3PPTWt7LXmgAsrKFCN+baQx4Q2YrHlu16yvKpmaZzPHJ/C5IjucUNbdceTs6Ef99IWzju0d8Hl5Z5UTMspYIhQ==,iv:JqnL3zfCd/xMRqTciA/Q6nYmFKzJkBqda4zucsE5KFw=,tag:RGZ/0/NEpdchj9h/l3Z7Ig==,type:str] +pilot_password: ENC[AES256_GCM,data:PiKJCv5x68O9HFM4UvqLnsSPtqFslBLeAg67OkvFAbw7WaqbXh/p5SQblhPHcJ7jQDc4kI3XesOxruZrfJ0aZNDV1g7MWecgKg==,iv:EVs/m83Zfx2NRQMO52cF6pCe1ETpYfaR6lmXg2Na/DI=,tag:dl2x1aTsaTgtHEZYdW2lmg==,type:str] cloudflare_dns_api_token: ENC[AES256_GCM,data:SAIMCvKOpGb5g9s03Xapc08KpOgLI+qlT5oiH/uNGxV+9JFSX3nvmQ==,iv:HFKcmHRG4EEOuJ8gRD0ZWsE18SLaZjewMSLznboLUeI=,tag:z21GURSxvNmZ4qkbri9mDQ==,type:str] sops: kms: [] @@ -34,8 +34,8 @@ sops: WFd4ZFNHWG5Cakw5cU9MRE9HWHQ4THMKr/S7v1Oj3zQziMtI/NuFVm6AaJF5JV5U sEr2nEptYFz4G6YL5psQGXHaKzQKBg+crgKRbYL4akhqT7pfYPC0bQ== -----END AGE ENCRYPTED FILE----- - lastmodified: "2024-05-09T01:31:33Z" - mac: ENC[AES256_GCM,data:W7sfnSzxLNAjdLtgwIlYhjaxa3gobh8El/cVggJTOiJVm1bC5TdLd0rUSh7J0UkvGj/lfPYjDDtYayaf09pjo8vLrZvH1SIy5wVF0ggcLM0tJxVqV8MDS+5pdUJiDOTfMiX1hyMBRH+N75PIqUMCte5x2zJg/79JMjch+E3NmA8=,iv:OAlKpC/2pz0ilwCNaBTsqTR/wNz6ZIVDgohDT8RvE5Y=,tag:VFAgHyr+DiWEeGaCSCh6og==,type:str] + lastmodified: "2024-05-20T18:01:20Z" + mac: ENC[AES256_GCM,data:6B+Oo7R2QhfD/1Nv+RMafWvoOTyC6qefFrdgfVu5DjSoAjucWV+8d0l5KgFude3ju4WWDi+Jv4boN/0pGEmgqaztTiSuLStzSoVcqYSUxHxSLjl2XJycqptcFN37GUCqCpyRpN6me1sylaTqbCUtd2acd+v/9Z12bXiGGvNY+Qc=,iv:6VGZmHbMFlCjkKIN8gvkJYQjQsIF0gQZQ1WNpn01UHk=,tag:3uvqMXaG/A/qqq9LRlR27w==,type:str] pgp: [] unencrypted_suffix: _unencrypted version: 3.8.1 diff --git a/hosts/nixos/common/users/guest.nix b/hosts/nixos/common/users/guest.nix index 5a716d7..e301080 100644 --- a/hosts/nixos/common/users/guest.nix +++ b/hosts/nixos/common/users/guest.nix @@ -1,4 +1,4 @@ -# For more comments check out [adrielus](./adrielus.nix) +# For more comments check out [pilot](./pilot.nix) { pkgs, outputs, lib, ... }: { users.mutableUsers = false; diff --git a/hosts/nixos/common/users/adrielus.nix b/hosts/nixos/common/users/pilot.nix similarity index 76% rename from hosts/nixos/common/users/adrielus.nix rename to hosts/nixos/common/users/pilot.nix index 0c22bcd..03fc1b8 100644 --- a/hosts/nixos/common/users/adrielus.nix +++ b/hosts/nixos/common/users/pilot.nix @@ -1,6 +1,8 @@ { pkgs, outputs, config, lib, ... }: { - sops.secrets.adrielus_password = { + satellite.pilot.name = "adrielus"; + + sops.secrets.pilot_password = { sopsFile = ../secrets.yaml; neededForUsers = true; }; @@ -9,13 +11,14 @@ # Configure users through nix only mutableUsers = false; - # Create an user named adrielus - users.adrielus = { + users.pilot = { + inherit (config.satellite.pilot) name; + # Adds me to some default groups, and creates the home dir isNormalUser = true; # Picked up by our persistence module - homeMode = "755"; + homeMode = "700"; # Add user to the following groups extraGroups = [ @@ -27,7 +30,7 @@ "syncthing" # syncthing! ]; - hashedPasswordFile = config.sops.secrets.adrielus_password.path; + hashedPasswordFile = config.sops.secrets.pilot_password.path; shell = pkgs.fish; openssh.authorizedKeys.keyFiles = diff --git a/hosts/nixos/lapetus/default.nix b/hosts/nixos/lapetus/default.nix index 3198d12..fe4a6c2 100644 --- a/hosts/nixos/lapetus/default.nix +++ b/hosts/nixos/lapetus/default.nix @@ -1,7 +1,7 @@ { imports = [ ../common/global - ../common/users/adrielus.nix + ../common/users/pilot.nix ../common/optional/services/kanata.nix ./services/syncthing.nix diff --git a/hosts/nixos/lapetus/services/qbittorrent.nix b/hosts/nixos/lapetus/services/qbittorrent.nix index d8b2fd8..f70f3f2 100644 --- a/hosts/nixos/lapetus/services/qbittorrent.nix +++ b/hosts/nixos/lapetus/services/qbittorrent.nix @@ -4,7 +4,7 @@ { config, pkgs, ... }: let port = 8417; - dataDir = "/persist/data/home/adrielus/media"; + dataDir = "/persist/data/${config.users.users.pilot.home}/media"; configDir = "/persist/state/var/lib/qbittorrent"; vpnConfigDir = "/persist/state/var/lib/openvpn"; in diff --git a/hosts/nixos/lapetus/services/zfs.nix b/hosts/nixos/lapetus/services/zfs.nix index 0da85e9..070b7fd 100644 --- a/hosts/nixos/lapetus/services/zfs.nix +++ b/hosts/nixos/lapetus/services/zfs.nix @@ -36,4 +36,12 @@ # }}} }; # }}} + # {{{ Syncoid + # Automatically sync certain snapshot to rsync.net + services.syncoid = { + enable = true; + commands."zroot/root/persist/data".target = "root@rsync.net:zroot/root/persist/data"; + commands."zroot/root/persist/state".target = "root@rsync.net:zroot/root/persist/state"; + }; + # }}} } diff --git a/hosts/nixos/tethys/default.nix b/hosts/nixos/tethys/default.nix index b19a034..2968ea8 100644 --- a/hosts/nixos/tethys/default.nix +++ b/hosts/nixos/tethys/default.nix @@ -2,7 +2,7 @@ # {{{ Imports imports = [ ../common/global - ../common/users/adrielus.nix + ../common/users/pilot.nix ../common/optional/pipewire.nix ../common/optional/bluetooth.nix diff --git a/hosts/nixos/tethys/services/syncthing.nix b/hosts/nixos/tethys/services/syncthing.nix index d673c77..54cf9d6 100644 --- a/hosts/nixos/tethys/services/syncthing.nix +++ b/hosts/nixos/tethys/services/syncthing.nix @@ -1,3 +1,4 @@ +{ config, ... }: let commonVersioning = { type = "staggered"; params = { @@ -11,7 +12,7 @@ in services.syncthing.settings.folders = { "stellar-sanctum" = { - path = "/home/adrielus/projects/stellar-sanctum/"; + path = "${config.users.users.pilot.home}/projects/stellar-sanctum/"; devices = [ "enceladus" "lapetus" ]; versioning = commonVersioning; }; diff --git a/modules/README.md b/modules/README.md index e323b6b..b388f86 100644 --- a/modules/README.md +++ b/modules/README.md @@ -7,34 +7,35 @@ This directory contains custom module definitions used throughout my config. | Directory | Description | | ------------------------------ | -------------------------------------------------------------- | | [common](./common) | Modules usable in both HM and nixos (and perhaps other places) | -| [nixos](./nixos) | Nixos specific functionality | +| [nixos](./nixos) | Nixos specific functionality | | [home-manager](./home-manager) | Home manager specific functionality | ## Common modules -| Name | Attribute | Description | Dependencies | -| ----------------------------------------------- | --------------------------- | ---------------------------------------- | ---------------------------------------------- | -| [lua-colorscheme](./common/lua-colorscheme.nix) | `satellite.colorscheme.lua` | Base16 theme to lua module generation | [stylix](https://github.com/danth/stylix) | -| [lua-lib](./common/lua-lib.nix) | `satellite.lib.lua` | Helpers for working with lua code | | -| [korora-lua](./common/korora-lua.nix) | - | Nix -> lua encoder | [korora](https://github.com/adisbladis/korora) | -| [korora-neovim](./common/korora-neovim.nix) | - | Nix -> neovim config helpers | [korora](https://github.com/adisbladis/korora) | -| [theming](./common/theming.nix) | `satellite.theming` | Base16 theming helpers and configuration | [stylix](https://github.com/danth/stylix) | -| [toggles](./common/toggles.nix) | `satellite.toggles` | Generic interface for feature flags | | +| Name | Attribute | Description | +| ----------------------------------------------- | --------------------------- | --------------------------------------------------------------------------------------------- | +| [toggles](./common/toggles.nix) | `satellite.toggles` | Generic interface for feature flags | +| [lua-lib](./common/lua-lib.nix) | `satellite.lib.lua` | Helpers for working with lua code | +| [korora-lua](./common/korora-lua.nix) | - | Nix -> lua encoder typechecked using [korora](https://github.com/adisbladis/korora) | +| [korora-neovim](./common/korora-neovim.nix) | - | Nix -> neovim config helpers typechecked using [korora](https://github.com/adisbladis/korora) | +| [theming](./common/theming.nix) | `satellite.theming` | [stylix](https://github.com/danth/stylix) theming helpers and configuration | +| [lua-colorscheme](./common/lua-colorscheme.nix) | `satellite.colorscheme.lua` | Base16 theme to lua module generation | ## Nixos modules -| Name | Attribute | Description | Dependencies | -| ---------------------------- | ----------------- | ---------------------------------------- | ------------ | -| [pounce](./nixos/pounce.nix) | `services.pounce` | Module for pounce & calico configuration | | -| [nginx](./nixos/nginx.nix) | `satellite.proxy` | Helpers for nginx configuration | | +| Name | Attribute | Description | +| -------------------------------------- | ----------------------- | ------------------------------------------- | +| [pounce](./nixos/pounce.nix) | `services.pounce` | Module for pounce & calico configuration | +| [nginx](./nixos/nginx.nix) | `satellite.proxy` | Helpers for nginx configuration | +| [cloudflared](./nixos/cloudflared.nix) | `satellite.cloudflared` | Helpers for cloudflare tunnel configuration | +| [pilot](./nixos/pilot.nix) | `satellite.pilot` | Defined the concept of a "main user" | ## Home-manager modules -| Name | Attribute | Description | Dependencies | -| ------------------------------------------------- | ----------------------- | --------------------------------------------------------------------------------- | ------------------------------------------------------------- | -| [discord](./home-manager/discord.nix) | `programs.discord` | Additional discord options | | -| [firefox](./home-manager/firefox) | `programs.firefox.apps` | Hacky system for wrapping websites into desktop apps by hiding the firefox tabbar | | -| [hyprpaper](./home-manager/hyprpaper.nix) | `services.hyprpaper` | Wallpaper service for `hyprland` | | -| [monitors](./home-manager/monitors.nix) | `satellite.monitors` | WM generic monitor configuration | | -| [persistence](./home-manager/persistence.nix) | `satellite.persistence` | Syntactic wrapper around impermanence | [impermanence](https://github.com/nix-community/impermanence) | -| [satellite-dev](./home-manager/satellite-dev.nix) | `satellite.dev` | Helpers for managing dotfiles which are actively under development | | +| Name | Attribute | Description | +| ------------------------------------------------- | ----------------------- | -------------------------------------------------------------------------------------- | +| [discord](./home-manager/discord.nix) | `programs.discord` | Additional discord options | +| [firefox](./home-manager/firefox) | `programs.firefox.apps` | Hacky system for wrapping websites into desktop apps by hiding the firefox tabbar | +| [monitors](./home-manager/monitors.nix) | `satellite.monitors` | WM generic monitor configuration | +| [persistence](./home-manager/persistence.nix) | `satellite.persistence` | Syntactic wrapper around [impermanence](https://github.com/nix-community/impermanence) | +| [satellite-dev](./home-manager/satellite-dev.nix) | `satellite.dev` | Helpers for managing dotfiles which are actively under development | diff --git a/modules/home-manager/compat/hyprpaper.nix b/modules/home-manager/compat/hyprpaper.nix new file mode 100644 index 0000000..7cd61c1 --- /dev/null +++ b/modules/home-manager/compat/hyprpaper.nix @@ -0,0 +1,135 @@ +{ config, lib, pkgs, ... }: +with lib; +let + cfg = config.services.hyprpaper; + toHyprconf = { attrs, indentLevel ? 0, importantPrefixes ? [ "$" ], }: + let + inherit (lib) + all concatMapStringsSep concatStrings concatStringsSep filterAttrs foldl + generators hasPrefix isAttrs isList mapAttrsToList replicate; + + initialIndent = concatStrings (replicate indentLevel " "); + + toHyprconf' = indent: attrs: + let + sections = + filterAttrs (n: v: isAttrs v || (isList v && all isAttrs v)) attrs; + + mkSection = n: attrs: + if lib.isList attrs then + (concatMapStringsSep "\n" (a: mkSection n a) attrs) + else '' + ${indent}${n} { + ${toHyprconf' " ${indent}" attrs}${indent}} + ''; + + mkFields = generators.toKeyValue { + listsAsDuplicateKeys = true; + inherit indent; + }; + + allFields = + filterAttrs (n: v: !(isAttrs v || (isList v && all isAttrs v))) + attrs; + + isImportantField = n: _: + foldl (acc: prev: if hasPrefix prev n then true else acc) false + importantPrefixes; + + importantFields = filterAttrs isImportantField allFields; + + fields = builtins.removeAttrs allFields + (mapAttrsToList (n: _: n) importantFields); + in + mkFields importantFields + + concatStringsSep "\n" (mapAttrsToList mkSection sections) + + mkFields fields; + in + toHyprconf' initialIndent attrs; +in +{ + meta.maintainers = [ maintainers.khaneliman maintainers.fufexan ]; + + options.services.hyprpaper = { + enable = mkEnableOption "Hyprpaper, Hyprland's wallpaper daemon"; + + package = mkPackageOption pkgs "hyprpaper" { }; + + settings = lib.mkOption { + type = with lib.types; + let + valueType = nullOr + (oneOf [ + bool + int + float + str + path + (attrsOf valueType) + (listOf valueType) + ]) // { + description = "Hyprpaper configuration value"; + }; + in + valueType; + default = { }; + description = '' + hyprpaper configuration written in Nix. Entries with the same key + should be written as lists. Variables' and colors' names should be + quoted. See for more examples. + ''; + example = lib.literalExpression '' + { + ipc = "on"; + splash = false; + splash_offset = 2.0; + + preload = + [ "/share/wallpapers/buttons.png" "/share/wallpapers/cat_pacman.png" ]; + + wallpaper = [ + "DP-3,/share/wallpapers/buttons.png" + "DP-1,/share/wallpapers/cat_pacman.png" + ]; + } + ''; + }; + + importantPrefixes = lib.mkOption { + type = with lib.types; listOf str; + default = [ "$" ]; + example = [ "$" ]; + description = '' + List of prefix of attributes to source at the top of the config. + ''; + }; + }; + + config = mkIf cfg.enable { + xdg.configFile."hypr/hyprpaper.conf" = mkIf (cfg.settings != { }) { + text = toHyprconf { + attrs = cfg.settings; + inherit (cfg) importantPrefixes; + }; + }; + + systemd.user.services.hyprpaper = { + Install = { WantedBy = [ "graphical-session.target" ]; }; + + Unit = { + ConditionEnvironment = "WAYLAND_DISPLAY"; + Description = "hyprpaper"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + X-Restart-Triggers = + [ "${config.xdg.configFile."hypr/hyprpaper.conf".source}" ]; + }; + + Service = { + ExecStart = "${getExe cfg.package}"; + Restart = "always"; + RestartSec = "10"; + }; + }; + }; +} diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix index 81c7aed..aa9eac4 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -3,16 +3,17 @@ { # example = import ./example.nix; + # Modules not yet added to the stable branch bemenu = import ./compat/bemenu.nix; + hyprpaper = import ./compat/hyprpaper.nix; k9s = import ./compat/k9s.nix; # Personal things + dev = import ./dev.nix; firefox = import ./firefox; monitors = import ./monitors.nix; - satellite-dev = import ./satellite-dev.nix; satellite-persistence = import ./persistence.nix; # Should upstream discord = import ./discord.nix; - hyprpaper = import ./hyprpaper.nix; } diff --git a/modules/home-manager/satellite-dev.nix b/modules/home-manager/dev.nix similarity index 100% rename from modules/home-manager/satellite-dev.nix rename to modules/home-manager/dev.nix diff --git a/modules/home-manager/discord.nix b/modules/home-manager/discord.nix index d23c6ea..4c004fb 100644 --- a/modules/home-manager/discord.nix +++ b/modules/home-manager/discord.nix @@ -4,7 +4,6 @@ in { options.programs.discord = { enable = lib.mkEnableOption "Discord"; - enableOpenASAR = lib.mkEnableOption "openASAR"; disableUpdateCheck = lib.mkEnableOption "update skipping"; enableDevtools = lib.mkEnableOption "devtools"; @@ -16,19 +15,13 @@ in }; config = lib.mkIf cfg.enable { - home.packages = - [ - (if cfg.enableOpenASAR - then cfg.package.override { withOpenASAR = true; } - else cfg.package) - ]; + home.packages = [ cfg.package ]; xdg.configFile."discord/settings.json".text = - builtins.toJSON - { - SKIP_HOST_UPDATE = cfg.disableUpdateCheck; - DANGEROUS_ENABLE_DEVTOOLS_ONLY_ENABLE_IF_YOU_KNOW_WHAT_YOURE_DOING = cfg.enableDevtools; - }; + builtins.toJSON { + SKIP_HOST_UPDATE = cfg.disableUpdateCheck; + DANGEROUS_ENABLE_DEVTOOLS_ONLY_ENABLE_IF_YOU_KNOW_WHAT_YOURE_DOING = cfg.enableDevtools; + }; }; } diff --git a/modules/home-manager/hyprpaper.nix b/modules/home-manager/hyprpaper.nix deleted file mode 100644 index c415920..0000000 --- a/modules/home-manager/hyprpaper.nix +++ /dev/null @@ -1,113 +0,0 @@ -# TODO: add maintainers and upstream into home-manager -{ config, lib, pkgs, ... }: - -with lib; - -let - cfg = config.services.hyprpaper; - mkWallpaper = { mode, image, monitor, ... }: - let - monitorString = lib.optionalString (monitor != null) monitor; - modeString = lib.optionalString (mode == "contain") "contain:"; - in - "wallpaper=${monitorString},${modeString}${image}"; -in -{ - options.services.hyprpaper = { - enable = mkEnableOption "hyprpaper"; - - package = mkOption { - type = types.package; - default = pkgs.hyprpaper; - defaultText = "pkgs.hyprpaper"; - description = '' - hyprpaper derivation to use. - ''; - }; - - # TODO: what should the default value be for this? - systemdTarget = mkOption { - type = types.str; - description = '' - Systemd target to bind to. - ''; - }; - - preload = mkOption { - type = types.listOf (types.oneOf [ types.str types.path ]); - default = [ ]; - example = [ "~/background.png" ]; - description = "List of images to preload"; - }; - - wallpapers = mkOption { - type = types.listOf (types.submodule (_: { - options = { - monitor = mkOption { - type = types.nullOr types.str; - default = null; - example = "eDP-1"; - description = '' - Monitor to use for the wallpaper. - Either leave empty as a wildcard, - type the name of the monitor, or - include the monitor's description - prefixed with `desc:`. - ''; - }; - - image = mkOption { - type = types.oneOf [ types.str types.path ]; - default = null; - example = "~/background.png"; - description = "Image to use as wallpaper"; - }; - - mode = mkOption { - type = lib.types.enum [ "cover" "contain" ]; - default = "cover"; - example = "contain"; - description = "The way to display the wallpaper"; - }; - }; - })); - - default = [ ]; - description = "List of wallpapers to set"; - }; - }; - - config = mkIf cfg.enable { - assertions = [ - (lib.hm.assertions.assertPlatform "services.hyprpaper" pkgs - lib.platforms.linux) - ]; - - xdg.configFile."hypr/hyprpaper.conf" = { - text = '' - ${lib.concatStringsSep "\n" (lib.forEach cfg.preload (image: "preload=${image}"))} - ${lib.concatStringsSep "\n" (lib.forEach cfg.wallpapers mkWallpaper)} - splash=true - ''; - - onChange = (pkgs.writeShellScript "reload_hyprpaper" '' - ${pkgs.systemd}/bin/systemctl --user restart hyprpaper.service - '').outPath; - }; - - systemd.user.services.hyprpaper = { - Unit = { - Description = "Hyprland wallpaper daemon"; - Requires = [ "graphical-session.target" ]; - }; - - Service = { - ExecStart = "${cfg.package}/bin/hyprpaper"; - }; - - Install = { - WantedBy = [ cfg.systemdTarget ]; - }; - }; - }; -} diff --git a/modules/home-manager/persistence.nix b/modules/home-manager/persistence.nix index 3145f0c..9831c03 100644 --- a/modules/home-manager/persistence.nix +++ b/modules/home-manager/persistence.nix @@ -1,35 +1,51 @@ -# My own module with nicer syntax for impernanence +# My own module with nicer syntax for impernanence { lib, config, ... }: let cfg = config.satellite.persistence; in { + # {{{ Option definition options.satellite.persistence = { - enable = lib.mkEnableOption "satellite persitence"; + enable = lib.mkEnableOption "satellite persistence"; at = lib.mkOption { default = { }; description = "Record of persistent locations (eg: /persist)"; - type = lib.types.attrsOf (lib.types.submodule (_: { + type = lib.types.attrsOf (lib.types.submodule (args: { + config = { + home = "${args.config.path}${config.home.homeDirectory}"; + }; + options = { + # {{{ Location options path = lib.mkOption { type = lib.types.str; example = "/persist"; - default = null; - description = "The location to store the files described in this record"; + description = "The root location to store the home directory for files in this record"; + }; + + home = lib.mkOption { + type = lib.types.str; + description = "The path to the home directory for files in this record"; }; prefixDirectories = lib.mkOption { type = lib.types.bool; default = true; - example = false; description = "Whether to enable gnu/stow type prefix directories"; }; - + # }}} + # {{{ Apps apps = lib.mkOption { default = { }; - description = "The apps to be stores in this persistent location"; - type = lib.types.attrsOf (lib.types.submodule (_: { + description = "Record of gnu/stow-style apps to be stored in this location"; + type = lib.types.attrsOf (lib.types.submodule ({ name, ... }: { options = { + name = lib.mkOption { + type = lib.types.str; + default = name; + description = "The gnu/stow-style subdirectory name"; + }; + files = lib.mkOption { type = lib.types.listOf lib.types.str; default = [ ]; @@ -37,18 +53,21 @@ in description = '' A list of files in your home directory you want to link to persistent storage. Allows both absolute paths - and paths relative to the home directory. . + and paths relative to the home directory. ''; }; directories = lib.mkOption { default = [ ]; - description = "Modified version of home.persistence.*.directories which takes in absolute paths"; + description = '' + Modified version of `home.persistence.*.directories` which takes in absolute paths. + ''; + type = lib.types.listOf (lib.types.either lib.types.str (lib.types.submodule { options = { directory = lib.mkOption { type = lib.types.str; - default = null; + example = "/home/username/.config/nvim"; description = "The directory path to be linked."; }; @@ -68,23 +87,27 @@ in }; })); }; + # }}} }; })); }; }; - + # }}} + # {{{ Config generation config = let makeLocation = location: let - processPath = appName: value: + # {{{ Path processing + processPath = appName: path: let - suffix = "${lib.strings.removePrefix "${config.home.homeDirectory}/" (builtins.toString value)}"; + suffix = "${lib.strings.removePrefix "${config.home.homeDirectory}/" (builtins.toString path)}"; prefix = if location.prefixDirectories then "${appName}/" else ""; in - # lib.debug.traceSeq "\nProcessing path at location ${location.path} and app ${appName} from original path ${value} to ${prefix + suffix}" + # lib.debug.traceSeq "\nProcessing path at location ${location.path} and app ${appName} from original path ${value} to ${prefix + suffix}" (prefix + suffix); - + # }}} + # {{{ Constructors mkDirectory = appName: directory: if builtins.isAttrs directory then { method = directory.method; @@ -92,20 +115,24 @@ in } else processPath appName directory; - mkAppDirectory = appName: app: builtins.map (mkDirectory appName) app.directories; - mkAppFiles = appName: app: builtins.map (processPath appName) app.files; + mkAppDirectory = app: builtins.map (mkDirectory app.name) app.directories; + mkAppFiles = app: builtins.map (processPath app.name) app.files; + # }}} in - lib.attrsets.nameValuePair (location.path + config.home.homeDirectory) { + # {{{ Impermanence config generation + lib.attrsets.nameValuePair location.home { removePrefixDirectory = location.prefixDirectories; allowOther = true; directories = lib.lists.flatten - (lib.attrsets.mapAttrsToList mkAppDirectory location.apps); + (lib.attrsets.mapAttrsToList (_: mkAppDirectory) location.apps); files = lib.lists.flatten - (lib.attrsets.mapAttrsToList mkAppFiles location.apps); + (lib.attrsets.mapAttrsToList (_: mkAppFiles) location.apps); }; + # }}} in lib.mkIf cfg.enable { home.persistence = lib.attrsets.mapAttrs' (_: makeLocation) cfg.at; }; + # }}} } diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index 8470070..950c9f5 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -2,7 +2,8 @@ { # example = import ./example.nix; - cloudflaredd = import ./cloudflared.nix; + cloudflared = import ./cloudflared.nix; nginx = import ./nginx.nix; + pilot = import ./pilot.nix; pounce = import ./pounce.nix; } diff --git a/modules/nixos/pilot.nix b/modules/nixos/pilot.nix new file mode 100644 index 0000000..bbd49ef --- /dev/null +++ b/modules/nixos/pilot.nix @@ -0,0 +1,8 @@ +{ lib, ... }: { + options.satellite.pilot = { + name = lib.mkOption { + type = lib.types.str; + description = "The name of the main user for this machine, as defined by `users.users.\${name}`"; + }; + }; +} diff --git a/modules/nixos/pounce.nix b/modules/nixos/pounce.nix index 0956910..b83afbb 100644 --- a/modules/nixos/pounce.nix +++ b/modules/nixos/pounce.nix @@ -34,8 +34,7 @@ in # {{{ Options options.services.pounce = { # {{{ general options - enable = mkEnableOption - (lib.mdDoc "the Pounce IRC bouncer and Calico dispatcher"); + enable = mkEnableOption "the Pounce IRC bouncer and Calico dispatcher"; user = mkOption { type = types.str;