diff options
Diffstat (limited to 'modules/common/common')
-rw-r--r-- | modules/common/common/documentation.nix | 3 | ||||
-rw-r--r-- | modules/common/common/home-manager.nix | 12 | ||||
-rw-r--r-- | modules/common/common/networking.nix | 5 | ||||
-rw-r--r-- | modules/common/common/nix.nix | 157 | ||||
-rw-r--r-- | modules/common/common/secrets.nix | 21 | ||||
-rw-r--r-- | modules/common/common/shell/default.nix | 218 | ||||
-rw-r--r-- | modules/common/common/stylix.nix | 13 | ||||
-rw-r--r-- | modules/common/common/users.nix | 11 | ||||
-rw-r--r-- | modules/common/common/xdg.nix | 75 |
9 files changed, 302 insertions, 213 deletions
diff --git a/modules/common/common/documentation.nix b/modules/common/common/documentation.nix index e9d4a79..2202e11 100644 --- a/modules/common/common/documentation.nix +++ b/modules/common/common/documentation.nix @@ -4,7 +4,8 @@ this, ... }: -with lib; { +with lib; +{ config = mkMerge [ (mkIf this.isHeadful { hm.manual = { diff --git a/modules/common/common/home-manager.nix b/modules/common/common/home-manager.nix index 97d7286..3c9fa0e 100644 --- a/modules/common/common/home-manager.nix +++ b/modules/common/common/home-manager.nix @@ -4,17 +4,21 @@ localUsername ? lib.my.username, ... }: -with lib; { +with lib; +{ imports = [ - (mkAliasOptionModule ["hm"] ["home-manager" "users" localUsername]) + (mkAliasOptionModule [ "hm" ] [ + "home-manager" + "users" + localUsername + ]) ]; hm = { news.display = "silent"; # NOTE Inheriting directly from `system.stateVersion` does not work with # nix-darwin for some reason. - home.stateVersion = with builtins; - head (split "\n" (readFile "${inputs.nixpkgs}/.version")); + home.stateVersion = with builtins; head (split "\n" (readFile "${inputs.nixpkgs}/.version")); }; home-manager = { diff --git a/modules/common/common/networking.nix b/modules/common/common/networking.nix index e5d27d8..2e19162 100644 --- a/modules/common/common/networking.nix +++ b/modules/common/common/networking.nix @@ -1,3 +1,4 @@ -{pkgs, ...}: { - environment.systemPackages = with pkgs; [myip]; +{ pkgs, ... }: +{ + environment.systemPackages = with pkgs; [ myip ]; } diff --git a/modules/common/common/nix.nix b/modules/common/common/nix.nix index ecd5874..6cc32d3 100644 --- a/modules/common/common/nix.nix +++ b/modules/common/common/nix.nix @@ -4,96 +4,96 @@ lib, localUsername ? lib.my.username, pkgs, + pkgsPr, this, ... }: -with lib; { - _module.args = let - importNixpkgs = nixpkgs: - import nixpkgs { - inherit (config.nixpkgs) config; - inherit (this) system; - }; - in rec { - pkgsLocal = importNixpkgs "${config.my.home}/src/nixpkgs"; # Impure! - pkgsMaster = importNixpkgs inputs.nixpkgs-master; - pkgsStable = importNixpkgs inputs.nixpkgs-stable; - pkgsRev = rev: hash: - importNixpkgs (pkgs.fetchFromGitHub { - owner = "NixOS"; - repo = "nixpkgs"; - inherit rev hash; - }); - pkgsPr = pr: pkgsRev "refs/pull/${toString pr}/head"; - }; +with lib; +{ + _module.args = + let + importNixpkgs = + nixpkgs: + import nixpkgs { + inherit (config.nixpkgs) config; + inherit (this) system; + }; + in + rec { + pkgsLocal = importNixpkgs "${config.my.home}/src/nixpkgs"; # Impure! + pkgsMaster = importNixpkgs inputs.nixpkgs-master; + pkgsStable = importNixpkgs inputs.nixpkgs-stable; + pkgsRev = + rev: hash: + importNixpkgs ( + pkgs.fetchFromGitHub { + owner = "NixOS"; + repo = "nixpkgs"; + inherit rev hash; + } + ); + pkgsPr = pr: pkgsRev "refs/pull/${toString pr}/head"; + }; - nix = let - notSelfInputs = filterAttrs (n: _: n != "self") inputs; - in { - settings = { - # https://nixos.org/manual/nix/unstable/contributing/experimental-features.html#currently-available-experimental-features - # https://github.com/NixOS/nix/blob/master/src/libutil/experimental-features.cc - experimental-features = concatStringsSep " " [ - "flakes" - "nix-command" - "recursive-nix" - "repl-flake" - ]; + nixpkgs.overlays = with inputs; [ + self.overlays.default + (_: _: { + inherit (pkgsPr 298756 "sha256-AxNXEDRb9yEde0sPEBRxfXSAu/ZL6/BlOzSj+aoOlHk=") qolibri; + inherit (pkgsPr 298346 "sha256-CSEUeivyTWxVskjWzDUal8KYthk7UYMOM4KdjZyhV3o=") dmalloc; + }) + ]; - keep-derivations = - if this.isHeadful - then "true" - else "false"; - keep-outputs = - if this.isHeadful - then "true" - else "false"; + nix = + let + notSelfInputs = filterAttrs (n: _: n != "self") inputs; + in + { + settings = { + # https://nixos.org/manual/nix/unstable/contributing/experimental-features.html#currently-available-experimental-features + # https://github.com/NixOS/nix/blob/master/src/libutil/experimental-features.cc + experimental-features = concatStringsSep " " [ + "flakes" + "nix-command" + "recursive-nix" + "repl-flake" + ]; - flake-registry = "${inputs.flake-registry}/flake-registry.json"; + keep-derivations = if this.isHeadful then "true" else "false"; + keep-outputs = if this.isHeadful then "true" else "false"; - warn-dirty = false; + flake-registry = "${inputs.flake-registry}/flake-registry.json"; - keep-going = true; + warn-dirty = false; - substituters = [ - "https://azahi.cachix.org" - "https://cache.iog.io" - "https://cachix.cachix.org" - "https://nix-community.cachix.org" - "https://organist.cachix.org" - "https://pre-commit-hooks.cachix.org" - "https://tweag-nickel.cachix.org" - ]; - trusted-public-keys = [ - "azahi.cachix.org-1:2bayb+iWYMAVw3ZdEpVg+NPOHCXncw7WMQ0ElX1GO3s=" - "cachix.cachix.org-1:eWNHQldwUO7G2VkjpnjDbWwy4KQ/HNxht7H4SSoMckM=" - "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" - "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" - "organist.cachix.org-1:GB9gOx3rbGl7YEh6DwOscD1+E/Gc5ZCnzqwObNH2Faw=" - "pre-commit-hooks.cachix.org-1:Pkk3Panw5AW24TOv6kz3PvLhlH8puAsJTBbOPmBo7Rc=" - "tweag-nickel.cachix.org-1:GIthuiK4LRgnW64ALYEoioVUQBWs0jexyoYVeLDBwRA=" - ]; + keep-going = true; - trusted-users = ["root" localUsername]; - }; + substituters = [ + "https://azahi.cachix.org" + "https://nix-community.cachix.org" + ]; + trusted-public-keys = [ + "azahi.cachix.org-1:2bayb+iWYMAVw3ZdEpVg+NPOHCXncw7WMQ0ElX1GO3s=" + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + ]; - nixPath = - mapAttrsToList (n: v: "${n}=${v}") notSelfInputs - ++ ["nixfiles=${config.my.home}/src/nixfiles"]; + trusted-users = [ + "root" + localUsername + ]; + }; - registry = - mapAttrs (_: flake: {inherit flake;}) notSelfInputs - // {nixfiles.flake = inputs.self;}; - }; + nixPath = mapAttrsToList (n: v: "${n}=${v}") notSelfInputs ++ [ + "nixfiles=${config.my.home}/src/nixfiles" + ]; - nixpkgs.overlays = with inputs; [ - self.overlays.default - (_: _: { - }) - ]; + registry = mapAttrs (_: flake: { inherit flake; }) notSelfInputs // { + nixfiles.flake = inputs.self; + }; + }; environment = { - systemPackages = with pkgs; + systemPackages = + with pkgs; optionals this.isHeadful [ nix-top nix-tree @@ -104,9 +104,10 @@ with lib; { hm = { # Used primarily in conjunction with the "nixfiles" script. - home.file.".nix-defexpr/default.nix".text = let - hostname = strings.escapeNixIdentifier this.hostname; - in + home.file.".nix-defexpr/default.nix".text = + let + hostname = strings.escapeNixIdentifier this.hostname; + in optionalString this.isHeadful '' let self = builtins.getFlake "nixfiles"; diff --git a/modules/common/common/secrets.nix b/modules/common/common/secrets.nix index fdc2501..3c05c09 100644 --- a/modules/common/common/secrets.nix +++ b/modules/common/common/secrets.nix @@ -6,19 +6,24 @@ this, ... }: -with lib; { - imports = [(mkAliasOptionModule ["secrets"] ["age" "secrets"])]; +with lib; +{ + imports = [ + (mkAliasOptionModule [ "secrets" ] [ + "age" + "secrets" + ]) + ]; config = { age.identityPaths = - if this.isHeadful - then ["${config.my.home}/.ssh/id_${my.ssh.type}"] + if this.isHeadful then + [ "${config.my.home}/.ssh/id_${my.ssh.type}" ] else - map (attr: attr.path) (filter (attr: attr.type == my.ssh.type) - config.services.openssh.hostKeys); + map (attr: attr.path) (filter (attr: attr.type == my.ssh.type) config.services.openssh.hostKeys); - environment.systemPackages = with pkgs; [agenix]; + environment.systemPackages = with pkgs; [ agenix ]; - nixpkgs.overlays = [inputs.agenix.overlays.default]; + nixpkgs.overlays = [ inputs.agenix.overlays.default ]; }; } diff --git a/modules/common/common/shell/default.nix b/modules/common/common/shell/default.nix index 8c3fa8a..883bfae 100644 --- a/modules/common/common/shell/default.nix +++ b/modules/common/common/shell/default.nix @@ -6,53 +6,55 @@ this, ... }: -with lib; let +with lib; +let cfg = config.nixfiles.modules.common.shell; -in { +in +{ options.nixfiles.modules.common.shell.aliases = mkOption { description = "An attribute set of shell aliases."; type = with types; attrsOf str; - default = {}; + default = { }; }; config = { hm = { - imports = [inputs.nix-index-database.hmModules.nix-index]; + imports = [ inputs.nix-index-database.hmModules.nix-index ]; programs = { bash = { enable = true; - initExtra = let - aliasCompletions = - concatStringsSep "\n" - (mapAttrsToList - (name: _: "complete -F _complete_alias ${name}") - cfg.aliases); - in '' - # Apropriated from the default NixOS prompt settings. - if [ "$TERM" != "dumb" ] || [ -n "$INSIDE_EMACS" ]; then - PROMPT_COLOR="1;31m" - ((UID)) && PROMPT_COLOR="1;32m" - if [ -n "$INSIDE_EMACS" ] || [ "$TERM" = "eterm" ] || [ "$TERM" = "eterm-color" ]; then - PS1="\n\[\033[$PROMPT_COLOR\][\u@\h:\w]\\$\[\033[0m\] " - else - PS1="\n\[\033[$PROMPT_COLOR\][\[\e]0;\u@\h: \w\a\]\u@\h:\w]\\$\[\033[0m\] " - fi - if test "$TERM" = "xterm"; then - PS1="\[\033]2;\h:\u:\w\007\]$PS1" - fi - fi + initExtra = + let + aliasCompletions = concatStringsSep "\n" ( + mapAttrsToList (name: _: "complete -F _complete_alias ${name}") cfg.aliases + ); + in + '' + # Apropriated from the default NixOS prompt settings. + if [ "$TERM" != "dumb" ] || [ -n "$INSIDE_EMACS" ]; then + PROMPT_COLOR="1;31m" + ((UID)) && PROMPT_COLOR="1;32m" + if [ -n "$INSIDE_EMACS" ] || [ "$TERM" = "eterm" ] || [ "$TERM" = "eterm-color" ]; then + PS1="\n\[\033[$PROMPT_COLOR\][\u@\h:\w]\\$\[\033[0m\] " + else + PS1="\n\[\033[$PROMPT_COLOR\][\[\e]0;\u@\h: \w\a\]\u@\h:\w]\\$\[\033[0m\] " + fi + if test "$TERM" = "xterm"; then + PS1="\[\033]2;\h:\u:\w\007\]$PS1" + fi + fi - source "${./functions.bash}" + source "${./functions.bash}" - source "${getExe' pkgs.complete-alias "complete_alias"}" - ${aliasCompletions} + source "${getExe' pkgs.complete-alias "complete_alias"}" + ${aliasCompletions} - # https://github.com/garabik/grc?tab=readme-ov-file#bash - GRC_ALIASES=true - source ${pkgs.grc}/etc/profile.d/grc.sh - ''; + # https://github.com/garabik/grc?tab=readme-ov-file#bash + GRC_ALIASES=true + source ${pkgs.grc}/etc/profile.d/grc.sh + ''; shellOptions = [ "autocd" @@ -74,57 +76,109 @@ in { ]; shellAliases = - listToAttrs - (map - ({ - name, - value, - }: - nameValuePair name (with pkgs; let - pkg = - if this.isHeadful - then - (pkgs.coreutils.overrideAttrs (_: super: { - patches = - (super.patches or []) - ++ [ - (fetchpatch { - url = "https://raw.githubusercontent.com/jarun/advcpmv/a1f8b505e691737db2f7f2b96275802c45f65c59/advcpmv-0.9-9.4.patch"; - hash = "sha256-4fdqpkENPfra4nFQU4+xNrlfq6Dw/2JIZXUOMmdMtcM="; - }) - ]; - })) - else coreutils; - in "${getExe' pkg "coreutils"} --coreutils-prog=${value}")) - ( - let - mkAlias = { - name ? head command, - command, - }: { - inherit name; - value = concatStringsSep " " command; - }; + listToAttrs ( + map + ( + { name, value }: + nameValuePair name ( + with pkgs; + let + pkg = + if this.isHeadful then + (pkgs.coreutils.overrideAttrs ( + _: super: { + patches = (super.patches or [ ]) ++ [ + (fetchpatch { + url = "https://raw.githubusercontent.com/jarun/advcpmv/a1f8b505e691737db2f7f2b96275802c45f65c59/advcpmv-0.9-9.4.patch"; + hash = "sha256-4fdqpkENPfra4nFQU4+xNrlfq6Dw/2JIZXUOMmdMtcM="; + }) + ]; + } + )) + else + coreutils; + in + "${getExe' pkg "coreutils"} --coreutils-prog=${value}" + ) + ) + ( + let + mkAlias = + { + name ? head command, + command, + }: + { + inherit name; + value = concatStringsSep " " command; + }; - progressBar = optionalString this.isHeadful "--progress-bar"; - in [ - (mkAlias {command = ["cp" "--interactive" "--recursive" progressBar];}) - (mkAlias {command = ["mv" "--interactive" progressBar];}) - (mkAlias {command = ["rm" "--interactive=once"];}) - (mkAlias {command = ["ln" "--interactive"];}) - (mkAlias {command = ["mkdir" "--parents"];}) - (mkAlias {command = ["rmdir" "--parents"];}) - (mkAlias { - name = "lower"; - command = ["tr" "'[:upper:]'" "'[:lower:]'"]; - }) - (mkAlias { - name = "upper"; - command = ["tr" "'[:lower:]'" "'[:upper:]'"]; - }) - ] - )) - // (genAttrs ["grep" "egrep" "fgrep"] (name: "${pkgs.gnugrep}/bin/${name} --color=always")) + progressBar = optionalString this.isHeadful "--progress-bar"; + in + [ + (mkAlias { + command = [ + "cp" + "--interactive" + "--recursive" + progressBar + ]; + }) + (mkAlias { + command = [ + "mv" + "--interactive" + progressBar + ]; + }) + (mkAlias { + command = [ + "rm" + "--interactive=once" + ]; + }) + (mkAlias { + command = [ + "ln" + "--interactive" + ]; + }) + (mkAlias { + command = [ + "mkdir" + "--parents" + ]; + }) + (mkAlias { + command = [ + "rmdir" + "--parents" + ]; + }) + (mkAlias { + name = "lower"; + command = [ + "tr" + "'[:upper:]'" + "'[:lower:]'" + ]; + }) + (mkAlias { + name = "upper"; + command = [ + "tr" + "'[:lower:]'" + "'[:upper:]'" + ]; + }) + ] + ) + ) + // (genAttrs [ + "grep" + "egrep" + "fgrep" + ] (name: "${pkgs.gnugrep}/bin/${name} --color=always")) // cfg.aliases; }; @@ -134,7 +188,7 @@ in { nix-index-database.comma.enable = true; }; - home.packages = with pkgs; [grc]; + home.packages = with pkgs; [ grc ]; }; environment = { diff --git a/modules/common/common/stylix.nix b/modules/common/common/stylix.nix index 30bf582..f1b8f81 100644 --- a/modules/common/common/stylix.nix +++ b/modules/common/common/stylix.nix @@ -1,11 +1,8 @@ +{ lib, pkgs, ... }: +with lib; { - lib, - pkgs, - ... -}: -with lib; { imports = [ - (mkAliasOptionModule ["colors"] [ + (mkAliasOptionModule [ "colors" ] [ "lib" "stylix" "colors" @@ -45,12 +42,12 @@ with lib; { }; serif = { - package = pkgs.iosevka-bin.override {variant = "Etoile";}; + package = pkgs.iosevka-bin.override { variant = "Etoile"; }; name = "Iosevka Etoile"; }; sansSerif = { - package = pkgs.iosevka-bin.override {variant = "Aile";}; + package = pkgs.iosevka-bin.override { variant = "Aile"; }; name = "Iosevka Aile"; }; diff --git a/modules/common/common/users.nix b/modules/common/common/users.nix index aee0e38..dc1b32e 100644 --- a/modules/common/common/users.nix +++ b/modules/common/common/users.nix @@ -3,6 +3,13 @@ localUsername ? lib.my.username, ... }: -with lib; { - imports = [(mkAliasOptionModule ["my"] ["users" "users" localUsername])]; +with lib; +{ + imports = [ + (mkAliasOptionModule [ "my" ] [ + "users" + "users" + localUsername + ]) + ]; } diff --git a/modules/common/common/xdg.nix b/modules/common/common/xdg.nix index 04ca544..4463c15 100644 --- a/modules/common/common/xdg.nix +++ b/modules/common/common/xdg.nix @@ -1,18 +1,35 @@ +{ config, lib, ... }: +with lib; { - config, - lib, - ... -}: -with lib; { - imports = let - withBase = a: ["nixfiles" "modules" "common" "xdg" a]; - in [ - (mkAliasOptionModule ["dirs" "cache"] (withBase "cacheHome")) - (mkAliasOptionModule ["dirs" "config"] (withBase "configHome")) - (mkAliasOptionModule ["dirs" "data"] (withBase "dataHome")) - (mkAliasOptionModule ["dirs" "state"] (withBase "stateHome")) - (mkAliasOptionModule ["userDirs"] (withBase "userDirs")) - ]; + imports = + let + withBase = a: [ + "nixfiles" + "modules" + "common" + "xdg" + a + ]; + in + [ + (mkAliasOptionModule [ + "dirs" + "cache" + ] (withBase "cacheHome")) + (mkAliasOptionModule [ + "dirs" + "config" + ] (withBase "configHome")) + (mkAliasOptionModule [ + "dirs" + "data" + ] (withBase "dataHome")) + (mkAliasOptionModule [ + "dirs" + "state" + ] (withBase "stateHome")) + (mkAliasOptionModule [ "userDirs" ] (withBase "userDirs")) + ]; options.nixfiles.modules.common.xdg = { cacheHome = mkOption { @@ -33,21 +50,23 @@ with lib; { }; userDirs = mkOption { type = types.attrs; - default = let - inherit (config.my) home; - tmp = home + "/tmp"; - in { - enable = true; + default = + let + inherit (config.my) home; + tmp = home + "/tmp"; + in + { + enable = true; - desktop = tmp; - documents = "${home}/doc"; - download = tmp; - music = tmp; - pictures = tmp; - publicShare = "${home}/share"; - templates = tmp; - videos = tmp; - }; + desktop = tmp; + documents = "${home}/doc"; + download = tmp; + music = tmp; + pictures = tmp; + publicShare = "${home}/share"; + templates = tmp; + videos = tmp; + }; }; }; } |