diff --git a/lib/devos/devosSystem.nix b/lib/devos/devosSystem.nix index b0f53fd84..95da127bf 100644 --- a/lib/devos/devosSystem.nix +++ b/lib/devos/devosSystem.nix @@ -20,8 +20,7 @@ lib.nixosSystem (args // { # avoid unwanted systemd service startups # all strings in disabledModules get appended to modulesPath # so convert each to list which can be coerced to string - disabledModules = map (x: [ x ]) - (lib.remove modules.core suites.allProfiles); + disabledModules = map (x: [ x ]) suites.allProfiles; nix.registry = lib.mapAttrs (n: v: { flake = v; }) inputs; diff --git a/lib/devos/mkHosts.nix b/lib/devos/mkHosts.nix index 1d1bfce0e..ee670aad1 100644 --- a/lib/devos/mkHosts.nix +++ b/lib/devos/mkHosts.nix @@ -12,7 +12,8 @@ let ]; modules = { - core = "${self}/profiles/core"; + core = "${self}/modules/core"; + modOverrides = { config, overrideModulesPath, ... }: let inherit (overrides) modules disabledModules; @@ -24,7 +25,7 @@ let modules; }; - global = { config, ... }: { + global = { config, pkgs, ... }: { home-manager = { useGlobalPkgs = true; useUserPackages = true; @@ -33,8 +34,32 @@ let sharedModules = extern.userModules ++ (builtins.attrValues self.homeModules); }; + devos.defaults = { + shell = lib.mkDefault true; + fonts = lib.mkDefault true; + packages = lib.mkDefault true; + }; + + users.mutableUsers = false; + + services.earlyoom.enable = true; hardware.enableRedistributableFirmware = lib.mkDefault true; + nix.package = pkgs.nixFlakes; + + nix = { + autoOptimiseStore = true; + gc.automatic = true; + optimise.automatic = true; + + useSandbox = true; + + allowedUsers = [ "@wheel" ]; + trustedUsers = [ "root" "@wheel" ]; + }; + + nix.systemFeatures = [ "nixos-test" "benchmark" "big-parallel" "kvm" ]; + nix.nixPath = [ "nixpkgs=${nixos}" "nixos-config=${self}/compat/nixos" @@ -53,6 +78,11 @@ let experimental-features = ${lib.concatStringsSep " " experimentalFeatures } + min-free = 536870912 + keep-outputs = true + keep-derivations = true + fallback = true + ''; system.configurationRevision = lib.mkIf (self ? rev) self.rev; diff --git a/modules/core/default.nix b/modules/core/default.nix new file mode 100644 index 000000000..4dc031c54 --- /dev/null +++ b/modules/core/default.nix @@ -0,0 +1,133 @@ +{ config, lib, pkgs, ... }: +with lib; +let + cfg = config.devos.defaults; +in +{ + options = { + devos.defaults = { + shell = mkEnableOption "sane shell aliases and prompt"; + fonts = mkEnableOption "and install useful fonts"; + packages = mkEnableOption "useful packages in the environment"; + }; + }; + + config = mkMerge [ + (mkIf cfg.packages { + environment.systemPackages = with pkgs; [ + binutils + coreutils + curl + deploy-rs + direnv + dnsutils + dosfstools + fd + git + gotop + gptfdisk + iputils + jq + manix + moreutils + nix-index + nmap + ripgrep + skim + tealdeer + utillinux + whois + ]; + }) + (mkIf cfg.shell { + environment = { + shellInit = '' + export STARSHIP_CONFIG=${ + pkgs.writeText "starship.toml" + (fileContents ./starship.toml) + } + ''; + + + shellAliases = + let ifSudo = lib.mkIf config.security.sudo.enable; + in + { + # quick cd + ".." = "cd .."; + "..." = "cd ../.."; + "...." = "cd ../../.."; + "....." = "cd ../../../.."; + + # git + g = "git"; + + # grep + grep = "rg"; + gi = "grep -i"; + + # internet ip + myip = "dig +short myip.opendns.com @208.67.222.222 2>&1"; + + # nix + n = "nix"; + np = "n profile"; + ni = "np install"; + nr = "np remove"; + ns = "n search --no-update-lock-file"; + nf = "n flake"; + nepl = "n repl ''"; + srch = "ns nixos"; + orch = "ns override"; + nrb = ifSudo "sudo nixos-rebuild"; + mn = '' + manix "" | grep '^# ' | sed 's/^# \(.*\) (.*/\1/;s/ (.*//;s/^# //' | sk --preview="manix '{}'" | xargs manix + ''; + + # fix nixos-option + nixos-option = "nixos-option -I nixpkgs=${toString ../../compat}"; + + # sudo + s = ifSudo "sudo -E "; + si = ifSudo "sudo -i"; + se = ifSudo "sudoedit"; + + # top + top = "gotop"; + + # systemd + ctl = "systemctl"; + stl = ifSudo "s systemctl"; + utl = "systemctl --user"; + ut = "systemctl --user start"; + un = "systemctl --user stop"; + up = ifSudo "s systemctl start"; + dn = ifSudo "s systemctl stop"; + jtl = "journalctl"; + + }; + }; + programs.bash = { + promptInit = '' + eval "$(${pkgs.starship}/bin/starship init bash)" + ''; + interactiveShellInit = '' + eval "$(${pkgs.direnv}/bin/direnv hook bash)" + ''; + }; + }) + (mkIf cfg.fonts { + fonts = { + fonts = with pkgs; [ powerline-fonts dejavu_fonts ]; + + fontconfig.defaultFonts = { + + monospace = [ "DejaVu Sans Mono for Powerline" ]; + + sansSerif = [ "DejaVu Sans" ]; + + }; + }; + }) + ]; +} diff --git a/profiles/core/starship.toml b/modules/core/starship.toml similarity index 100% rename from profiles/core/starship.toml rename to modules/core/starship.toml diff --git a/profiles/core/default.nix b/profiles/core/default.nix deleted file mode 100644 index 1e789a497..000000000 --- a/profiles/core/default.nix +++ /dev/null @@ -1,150 +0,0 @@ -{ config, lib, pkgs, ... }: -let inherit (lib) fileContents; -in -{ - nix.package = pkgs.nixFlakes; - - nix.systemFeatures = [ "nixos-test" "benchmark" "big-parallel" "kvm" ]; - - environment = { - - systemPackages = with pkgs; [ - binutils - coreutils - curl - deploy-rs - direnv - dnsutils - dosfstools - fd - git - gotop - gptfdisk - iputils - jq - manix - moreutils - nix-index - nmap - ripgrep - skim - tealdeer - utillinux - whois - ]; - - shellInit = '' - export STARSHIP_CONFIG=${ - pkgs.writeText "starship.toml" - (fileContents ./starship.toml) - } - ''; - - shellAliases = - let ifSudo = lib.mkIf config.security.sudo.enable; - in - { - # quick cd - ".." = "cd .."; - "..." = "cd ../.."; - "...." = "cd ../../.."; - "....." = "cd ../../../.."; - - # git - g = "git"; - - # grep - grep = "rg"; - gi = "grep -i"; - - # internet ip - myip = "dig +short myip.opendns.com @208.67.222.222 2>&1"; - - # nix - n = "nix"; - np = "n profile"; - ni = "np install"; - nr = "np remove"; - ns = "n search --no-update-lock-file"; - nf = "n flake"; - nepl = "n repl ''"; - srch = "ns nixos"; - orch = "ns override"; - nrb = ifSudo "sudo nixos-rebuild"; - mn = '' - manix "" | grep '^# ' | sed 's/^# \(.*\) (.*/\1/;s/ (.*//;s/^# //' | sk --preview="manix '{}'" | xargs manix - ''; - - # fix nixos-option - nixos-option = "nixos-option -I nixpkgs=${toString ../../compat}"; - - # sudo - s = ifSudo "sudo -E "; - si = ifSudo "sudo -i"; - se = ifSudo "sudoedit"; - - # top - top = "gotop"; - - # systemd - ctl = "systemctl"; - stl = ifSudo "s systemctl"; - utl = "systemctl --user"; - ut = "systemctl --user start"; - un = "systemctl --user stop"; - up = ifSudo "s systemctl start"; - dn = ifSudo "s systemctl stop"; - jtl = "journalctl"; - - }; - }; - - fonts = { - fonts = with pkgs; [ powerline-fonts dejavu_fonts ]; - - fontconfig.defaultFonts = { - - monospace = [ "DejaVu Sans Mono for Powerline" ]; - - sansSerif = [ "DejaVu Sans" ]; - - }; - }; - - nix = { - - autoOptimiseStore = true; - - gc.automatic = true; - - optimise.automatic = true; - - useSandbox = true; - - allowedUsers = [ "@wheel" ]; - - trustedUsers = [ "root" "@wheel" ]; - - extraOptions = '' - min-free = 536870912 - keep-outputs = true - keep-derivations = true - fallback = true - ''; - - }; - - programs.bash = { - promptInit = '' - eval "$(${pkgs.starship}/bin/starship init bash)" - ''; - interactiveShellInit = '' - eval "$(${pkgs.direnv}/bin/direnv hook bash)" - ''; - }; - - services.earlyoom.enable = true; - - users.mutableUsers = false; - -}