diff --git a/hosts/sydpc/configuration.nix b/hosts/sydpc/configuration.nix index 702d37b..ceaa5b6 100644 --- a/hosts/sydpc/configuration.nix +++ b/hosts/sydpc/configuration.nix @@ -29,6 +29,7 @@ users.users = [ "crumb" + "msyds" ]; impermanence = { diff --git a/modules/home/emacs.nix b/modules/home/emacs.nix new file mode 100644 index 0000000..bb15252 --- /dev/null +++ b/modules/home/emacs.nix @@ -0,0 +1,141 @@ +{ config, lib, pkgs, inputs, ... }@args: + +let cfg = config.sydnix.emacs; +in { + options.sydnix.emacs = { + enable = lib.mkEnableOption "Emacs"; + userDir = lib.mkOption { + description = '' + The path to the Emacs user directory. + ''; + default = "/persist/dots/modules/home/users/msyds/emacs"; + type = lib.types.path; + }; + package = lib.mkPackageOption pkgs "emacs" { + default = [ "emacs-pgtk" ]; + }; + emacsPackages = lib.mkOption { + description = '' + Emacs packages to be installed. Used primarily for Elisp packages with + system dependencies. + ''; + default = _epkgs: []; + type = lib.types.anything // { + merge = + _loc: defs: epkgs: lib.concatMap (f: f epkgs) (lib.getValues defs); + check = lib.isFunction; + }; + }; + fontPackages = lib.mkOption { + description = '' + Font packages to be made available to Emacs. + ''; + type = lib.types.listOf lib.types.package; + default = []; + }; + files = [ + ]; + tex = { + enable = lib.mkEnableOption "TexLive"; + extraTexPackages = lib.mkOption { + description = '' + TexLive package to be made available. + ''; + default = {}; + type = lib.types.attrsOf lib.types.package; + }; + }; + extraWrapProgramArgs = lib.mkOption { + description = '' + Extra arguments to pass to the final wrapProgram call. + ''; + default = []; + type = lib.types.listOf lib.types.str; + apply = lib.escapeShellArgs; + }; + }; + + config = lib.mkIf cfg.enable + (let + emacsDataDir = "${config.xdg.dataHome}/emacs"; + emacsCacheDir = "${config.xdg.cacheHome}/emacs"; + + warnings = + if config.fonts.fontconfig.enable + then [] + else [''This Emacs config will have font issues if + fonts.fontconfig.enable is not enabled.'']; + + essentialTexPackages = { + inherit (pkgs.texlive) + scheme-basic # Set of common packages. + fontspec + dvisvgm dvipng wrapfig # For Org-mode previews/export. + amsmath # Essential for mathematics. + ulem hyperref + capt-of + pgf # Includes TikZ. + tikz-cd # Commutative diagrams w/ TikZ. + quiver # Commutative diagrams w/ TikZ & q.uiver.app. + metafont + preview # For new-gen org-latex-preview. + mylatexformat # For new-gen org-latex-preview. + collection-fontsrecommended # Essential fonts. + etoolbox # For Org-mode exports. + ; + }; + + my-texlive = pkgs.texlive.combine + (essentialTexPackages ++ cfg.tex.extraTexPackages); + + emacs-final = + let ewp = (pkgs.emacsPackagesFor cfg.package).emacsWithPackages + cfg.emacsPackages; + in pkgs.symlinkJoin { + name = "sydmacs"; + paths = [ ewp ]; + nativeBuildInputs = [ + pkgs.makeWrapper + ]; + postBuild = '' + # Read all emacs binaries into a Bash array. + readarray -d "" emacsen \ + < <(find "$out/bin" \( -name emacs -or -name 'emacs-*' \) -print0) + + for emacs in "''${emacsen[@]}"; do + wrapProgram "$emacs" \ + --add-flags "--init-directory \"${cfg.userDir}\"" \ + ${cfg.extraWrapProgramArgs} + done + ''; + meta = cfg.package.meta; + version = cfg.package.version; + }; + in { + programs.emacs = { + enable = true; + package = emacs-final; + }; + + sydnix.impermanence.cache.directories = [ + # Impermanence expects the path to be relative to ~. + (lib.removePrefix "${config.home.homeDirectory}/" emacsCacheDir) + ]; + + sydnix.impermanence.directories = [ + # Impermanence expects the path to be relative to ~. + (lib.removePrefix "${config.home.homeDirectory}/" emacsDataDir) + ]; + + home.packages = cfg.fontPackages; + + services.emacs = { + enable = true; + # Generate a desktop entry for emacsclient. + client.enable = true; + }; + + # We do this ourselves. + stylix.targets.emacs.enable = false; + }); +} diff --git a/modules/home/users/msyds/emacs.nix b/modules/home/users/msyds/emacs.nix new file mode 100644 index 0000000..fd9f6f4 --- /dev/null +++ b/modules/home/users/msyds/emacs.nix @@ -0,0 +1,24 @@ +{ config, lib, pkgs, inputs, ... }@args: + +let cfg = config.sydnix.users.msyds.emacs; +in { + options.sydnix.users.msyds.emacs = { + enable = lib.mkEnableOption ''Emacs, à la msyds''; + userDir = lib.mkOption { + description = '' + The path to the Emacs user directory. + ''; + default = "/persist/dots/modules/home/users/msyds/emacs"; + type = lib.types.path; + }; + package = lib.mkPackageOption pkgs "emacs" { + default = [ "emacs-pgtk" ]; + }; + }; + + config = lib.mkIf cfg.enable { + sydnix.emacs = { + enable = true; + }; + }; +} diff --git a/users/msyds/default.nix b/users/msyds/default.nix old mode 100755 new mode 100644 index 63f1ada..f415ca7 --- a/users/msyds/default.nix +++ b/users/msyds/default.nix @@ -1,70 +1,45 @@ { systemConfiguration = { config, ... }: { isNormalUser = true; - - # Unfortunately must be hard-coded so we can attribute it to the - # corresponding LDAP user. - uid = 1006; - # TODO: Don't hard-code `persist`. Use # config.sydnix.impermanence.persistGroupName. - extraGroups = [ - # Admin account. - "wheel" - # Default permissions to modify /persist. - "persist" - # Can modify the files served by Nginx. - "nginx" - # Can modify Deertopia's git-annex repos. - "annex" - # Can modify Deertopia's Jellyfin libraries. - "jellyfin" - # Can access slskd's downloads. - "slskd" - # Can access Nixarr's media. - "media" - "www" - ]; - + extraGroups = [ "wheel" "persist" "input" ]; initialHashedPassword = - "$y$j9T$aEFDDwdTZbAc6VQRXrkBJ0$K8wxTGTWDihyX1wxJ.ZMH//wmQFfrGGUkLkxIU0Lyq8"; + "$y$j9T$4pyDiPlhnN4UarQoY7Sn70$URZQKPJ3yU4WoQFHRhzm4uF3bM4U7OVYem3oPioykMC"; openssh.authorizedKeys.keyFiles = [ - ../../public-keys/ssh/crumb-at-guix-rebound.pub - ../../public-keys/ssh/crumb-at-nixos-testbed.pub - ../../public-keys/ssh/termux.pub ]; }; homeConfiguration = { config, lib, pkgs, ... }: { home.file.".ssh/id_ed25519".source = config.lib.file.mkOutOfStoreSymlink - "/persist/private-keys/ssh/lain-at-deertopia"; + "/persist/private-keys/ssh/crumb-at-nixos-testbed"; home.file.".ssh/id_ed25519.pub".source = - ../../public-keys/ssh/lain-at-deertopia.pub; + ../../public-keys/ssh/crumb-at-nixos-testbed.pub; - programs.bash.enable = true; + # A few settings without a home: + xdg.enable = true; + home.preferXdgDirectories = true; - home.sessionVariables = { - "EDITOR" = "nvim"; - "VISUAL" = "nvim"; - }; + home.packages = []; - home.packages = [ - pkgs.btop - ]; + fonts.fontconfig.enable = true; sydnix = { - impermanence = { - enable = true; - directories = [ - ".ssh" - "public" - ]; + xdg.enable = true; + # Personal configurations. + users.crumb = { + bash.enable = true; + direnv.enable = true; + git.enable = true; + nvim.enable = true; + readline.enable = true; + }; + users.msyds = { + emacs.enable = true; }; - users.crumb.git.enable = true; - users.crumb.nvim.enable = true; }; # Don't touch! diff --git a/users/msyds/files.nix b/users/msyds/files.nix deleted file mode 100644 index 41c54c9..0000000 --- a/users/msyds/files.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ config, lib, pkgs, ... }: - -let mutableSymlink = config.lib.file.mkOutOfStoreSymlink; -in { - home.file.".ssh/id_ed25519".source = - mutableSymlink "/persist/private-keys/ssh/lain-at-deertopia"; - home.file.".ssh/id_ed25519.pub".source = - ../../public-keys/ssh/lain-at-deertopia.pub; -} diff --git a/users/msyds/secrets.yaml b/users/msyds/secrets.yaml new file mode 100755 index 0000000..aee6b99 --- /dev/null +++ b/users/msyds/secrets.yaml @@ -0,0 +1,24 @@ +lastfm-password: ENC[AES256_GCM,data:gLcWwEFLhlVdMWez5Kaja17WFUA=,iv:KT9JO0823dn6qHnK2uOacMxHf4f776/soXFUVjUi1UA=,tag:n77bHc97yoKJPYvTCWhEuQ==,type:str] +librefm-password: ENC[AES256_GCM,data:0gDlWC/2CxryI6jH5RuJ,iv:8QVnhLko3H/IupQrNknxTR8NewfTP+DJyzvHk9Hzr48=,tag:Ku02Jp7p5G5qkO41Y3EFwA==,type:str] +github-oauth: ENC[AES256_GCM,data:t3FKFYu8edeBipC55nrG0lt1SCY8q1N5dZmvsCg7GLlVl4oDXW8FyQ==,iv:aewQ63H6c5wAw+YQRKbDT18Q05hSFsrdQBSYOUeVNeY=,tag:m1oCnSmLt+0rfcfSO4sOkQ==,type:str] +gitlab-oauth: ENC[AES256_GCM,data:1THznoGRZmq7BkisZoGa0ZiPG7aSmkV06SY=,iv:Gq6UPHBBrnpkiAo4CZipc89kJ9mfJrwIp9NmUmjtKBo=,tag:UhvgCQlnkTEQ4hEbCTM6ow==,type:str] +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1qayk0d0f765v57pedm7mtau6qkmv8rh6jtaqm40g5g9armaty4jqc0v0y2 + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSA2NE5mTER1OXpadmNzaXV6 + b3RSbS9yWTN0NWR4Z2xBRnRSanQxYXdRT2drClVrSk1raXE4ZUVIVmxoMzJWU1Rj + VmxzdnVSUVEvQk1JcFo4Qjh6YWhiME0KLS0tIHh1OCtzSUZpWWhrbXB4SlA4RVBs + VVBqSEM2bVFBU0M5YzZBQWIwUmVXUXMKvWb57Rc+rO5M8Pf7lvbSjuZB4FrHgT3A + uBQHH3wpv0BVVzL8tucPnwNxDnwpWvFxxwNVy/rtfs6y6HPu6fuOsA== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2025-01-04T06:44:34Z" + mac: ENC[AES256_GCM,data:6zIMlRUHqX0yWVX8CWo69QtutuYshHuNGJ3N+PTpwe6qawwrAAEOMK9Xg4PDu7GZDRWu89UBq3SLOB9DpzOzj1sNoQeokNBvO2AyY+3iBcwBgzX8GeN/A7VK/HPv7g6CuEwnwjvhZLYH74UzmzfXraxMMdx0wldoQE7HD8Ya49M=,iv:QpRtoBUEAyLjeoj4+xtfEibMZj0vhfcMZON3q7LBMBQ=,tag:Dd+Lomo+rg6/fgBRudtIUg==,type:str] + pgp: [] + unencrypted_suffix: _unencrypted + version: 3.9.1