Skip to content

Commit

Permalink
templates/snowfall/modules: cleanup pointless inherits
Browse files Browse the repository at this point in the history
  • Loading branch information
khaneliman committed Aug 30, 2024
1 parent ddd67a7 commit 4441f46
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 48 deletions.
9 changes: 4 additions & 5 deletions templates/snowfall/modules/darwin/home/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
...
}:
let
inherit (lib) types mkAliasDefinitions;
inherit (lib.${namespace}) mkOpt;
in
{

options.${namespace}.home = with types; {
options.${namespace}.home = with lib.types; {
file = mkOpt attrs { } "A set of files to be managed by home-manager's <option>home.file</option>.";
configFile =
mkOpt attrs { }
Expand All @@ -22,13 +21,13 @@ in

config = {
${namespace}.home.extraOptions = {
home.file = mkAliasDefinitions options.${namespace}.home.file;
home.file = lib.mkAliasDefinitions options.${namespace}.home.file;
xdg.enable = true;
xdg.configFile = mkAliasDefinitions options.${namespace}.home.configFile;
xdg.configFile = lib.mkAliasDefinitions options.${namespace}.home.configFile;
};

snowfallorg.users.${config.${namespace}.user.name}.home.config =
mkAliasDefinitions
lib.mkAliasDefinitions
options.${namespace}.home.extraOptions;

home-manager = {
Expand Down
8 changes: 3 additions & 5 deletions templates/snowfall/modules/darwin/nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
...
}:
let
inherit (lib) mkIf mkForce;

cfg = config.${namespace}.nix;
in
{
imports = [ (lib.snowfall.fs.get-file "modules/shared/nix/default.nix") ];

config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
nix = {
# Options that aren't supported through nix-darwin
extraOptions = ''
Expand Down Expand Up @@ -56,11 +54,11 @@ in

# Frequent issues with networking failures on darwin
# limit number to see if it helps
http-connections = mkForce 25;
http-connections = lib.mkForce 25;

# FIX: shouldn't disable, but getting sandbox max size errors on darwin
# darwin-rebuild --rollback on testing changing
sandbox = mkForce false;
sandbox = lib.mkForce false;
};
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,17 @@ in
# '$music' '$spotify' '$plex' '$small_blank' \
# '$code' '$github' '$gitkraken' '$small_blank' \
# '$alacritty' '$kitty'"
# Larger spacer
# {tile-data={}; tile-type="spacer-tile";}
# Small spacer
# ''{tile-data={}; tile-type="small-spacer-tile";}''
persistent-apps = [
"/System/Applications/Launchpad.app"
"/System/Applications/System Settings.app"
"/System/Applications/App Store.app"
# TODO: implement small_blank
# Need to update upstream to accept something like this
# ''{tile-data={}; tile-type="small-spacer-tile";}''
"/System/Applications/Messages.app"
"/Applications/Caprine.app"
"/Applications/Element.app"
Expand Down
34 changes: 14 additions & 20 deletions templates/snowfall/modules/nixos/system/env/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@
...
}:
let
inherit (lib)
types
concatStringsSep
mapAttrsToList
mkOption
mapAttrs
;

pagerArgs = [
"--RAW-CONTROL-CHARS" # Only allow colors.
"--wheel-lines=5"
Expand All @@ -24,18 +16,20 @@ let
cfg = config.${namespace}.system.env;
in
{
options.${namespace}.system.env =
with types;
mkOption {
apply = mapAttrs (_n: v: if isList v then concatMapStringsSep ":" toString v else (toString v));
default = { };
description = "A set of environment variables to set.";
type = attrsOf (oneOf [
options.${namespace}.system.env = lib.mkOption {
apply = lib.mapAttrs (
_n: v: if lib.isList v then lib.concatMapStringsSep ":" toString v else (toString v)
);
default = { };
description = "A set of environment variables to set.";
type =
with lib.types;
attrsOf (oneOf [
str
path
(listOf (either str path))
]);
};
};

config = {
environment = {
Expand All @@ -47,8 +41,8 @@ in
XDG_DESKTOP_DIR = "$HOME";
};

extraInit = concatStringsSep "\n" (
mapAttrsToList (
extraInit = lib.concatStringsSep "\n" (
lib.mapAttrsToList (
n: v: # bash
''
export ${n}="${v}"
Expand All @@ -69,8 +63,8 @@ in
MANPAGER = "nvim -c 'set ft=man bt=nowrite noswapfile nobk shada=\\\"NONE\\\" ro noma' +Man! -o -";
SYSTEMD_PAGERSECURE = "true";
PAGER = "less -FR";
LESS = concatStringsSep " " pagerArgs;
SYSTEMD_LESS = concatStringsSep " " (
LESS = lib.concatStringsSep " " pagerArgs;
SYSTEMD_LESS = lib.concatStringsSep " " (
pagerArgs
++ [
"--quit-if-one-screen"
Expand Down
26 changes: 8 additions & 18 deletions templates/snowfall/modules/shared/nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,22 @@
...
}:
let
inherit (lib)
filterAttrs
isType
mapAttrs
mapAttrsToList
mkDefault
mkIf
pipe
types
;
inherit (lib.${namespace}) mkBoolOpt mkOpt;

cfg = config.${namespace}.nix;
in
{
options.${namespace}.nix = with types; {
options.${namespace}.nix = {
enable = mkBoolOpt true "Whether or not to manage nix configuration.";
package = mkOpt package pkgs.nixVersions.latest "Which nix package to use.";
package = mkOpt lib.types.package pkgs.nixVersions.latest "Which nix package to use.";
};

config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
# faster rebuilding
documentation = {
doc.enable = false;
info.enable = false;
man.enable = mkDefault true;
man.enable = lib.mkDefault true;
};

environment = {
Expand All @@ -56,9 +46,9 @@ in

nix =
let
mappedRegistry = pipe inputs [
(filterAttrs (_: isType "flake"))
(mapAttrs (_: flake: { inherit flake; }))
mappedRegistry = lib.pipe inputs [
(lib.filterAttrs (_: lib.isType "flake"))
(lib.mapAttrs (_: flake: { inherit flake; }))
(x: x // { nixpkgs.flake = inputs.nixpkgs; })
];

Expand All @@ -79,7 +69,7 @@ in

# This will additionally add your inputs to the system's legacy channels
# Making legacy nix commands consistent as well
nixPath = mapAttrsToList (key: _: "${key}=flake:${key}") config.nix.registry;
nixPath = lib.mapAttrsToList (key: _: "${key}=flake:${key}") config.nix.registry;

optimise.automatic = true;

Expand Down

0 comments on commit 4441f46

Please sign in to comment.