Use nixfmt and nil

work
mat ess 2023-08-22 20:50:29 -04:00
parent 76323f62fb
commit be5c031895
27 changed files with 306 additions and 398 deletions

View File

@ -1,5 +1,4 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }: {
{
# Nix configuration ------------------------------------------------------------------------------ # Nix configuration ------------------------------------------------------------------------------
nix.settings = { nix.settings = {
@ -20,14 +19,15 @@
"pre-commit-hooks.cachix.org-1:Pkk3Panw5AW24TOv6kz3PvLhlH8puAsJTBbOPmBo7Rc=" "pre-commit-hooks.cachix.org-1:Pkk3Panw5AW24TOv6kz3PvLhlH8puAsJTBbOPmBo7Rc="
"iohk.cachix.org-1:DpRUyj7h7V830dp/i6Nti+NEO2/nhblbov/8MW7Rqoo=" "iohk.cachix.org-1:DpRUyj7h7V830dp/i6Nti+NEO2/nhblbov/8MW7Rqoo="
]; ];
trusted-users = [ trusted-users = [ "@admin" ];
"@admin"
];
# TODO: remove and replace with a launchd job # TODO: remove and replace with a launchd job
# see https://github.com/NixOS/nix/issues/7273 # see https://github.com/NixOS/nix/issues/7273
auto-optimise-store = true; auto-optimise-store = true;
experimental-features = [ "nix-command" "flakes" ]; experimental-features = [ "nix-command" "flakes" ];
extra-platforms = lib.mkIf (pkgs.system == "aarch64-darwin") [ "x86_64-darwin" "aarch64-darwin" ]; extra-platforms = lib.mkIf (pkgs.system == "aarch64-darwin") [
"x86_64-darwin"
"aarch64-darwin"
];
}; };
nix.configureBuildUsers = true; nix.configureBuildUsers = true;
@ -35,12 +35,8 @@
services.nix-daemon.enable = true; services.nix-daemon.enable = true;
# Make Fish the default shell # Make Fish the default shell
environment.shells = lib.mkForce (builtins.attrValues { environment.shells = lib.mkForce
inherit (pkgs) (builtins.attrValues { inherit (pkgs) bashInteractive fish zsh; });
bashInteractive
fish
zsh;
});
programs.fish.enable = true; programs.fish.enable = true;
programs.fish.useBabelfish = true; programs.fish.useBabelfish = true;

View File

@ -2,8 +2,7 @@
let let
inherit (config.users) primaryUser; inherit (config.users) primaryUser;
caskPresent = cask: lib.any (x: x.name == cask) config.homebrew.casks; caskPresent = cask: lib.any (x: x.name == cask) config.homebrew.casks;
in in {
{
environment.shellInit = '' environment.shellInit = ''
eval "$(${config.homebrew.brewPrefix}/brew shellenv)" eval "$(${config.homebrew.brewPrefix}/brew shellenv)"
''; '';
@ -87,17 +86,14 @@ in
# "zoom" # "zoom"
]; ];
home-manager.users.${primaryUser.username} = home-manager.users.${primaryUser.username} = let
let socket =
socket = "${primaryUser.homeDirectory}/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh"; "${primaryUser.homeDirectory}/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh";
in in lib.mkIf (caskPresent "secretive" && config ? home-manager) {
lib.mkIf (caskPresent "secretive" && config ? home-manager) {
home.sessionVariables.SSH_AUTH_SOCK = socket; home.sessionVariables.SSH_AUTH_SOCK = socket;
programs.ssh = { programs.ssh = {
enable = true; enable = true;
matchBlocks."*".extraOptions = { matchBlocks."*".extraOptions = { IdentityAgent = socket; };
IdentityAgent = socket;
};
}; };
}; };

View File

@ -1,14 +1,7 @@
# See https://nixos.wiki/wiki/Flakes#Using_flakes_project_from_a_legacy_Nix # See https://nixos.wiki/wiki/Flakes#Using_flakes_project_from_a_legacy_Nix
(import (import (let lock = builtins.fromJSON (builtins.readFile ./flake.lock);
( in fetchTarball {
let url =
lock = builtins.fromJSON (builtins.readFile ./flake.lock); "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash; sha256 = lock.nodes.flake-compat.locked.narHash;
} }) { src = ./.; }).defaultNix
)
{
src = ./.;
}).defaultNix

View File

@ -42,12 +42,7 @@
starship-src.flake = false; starship-src.flake = false;
}; };
outputs = outputs = { self, flake-utils, pre-commit, ... }@inputs:
{ self
, flake-utils
, pre-commit
, ...
}@inputs:
let let
# this is a "functor" that takes an option name # this is a "functor" that takes an option name
# this allows for creating identical modules # this allows for creating identical modules
@ -55,10 +50,7 @@
mkPrimaryUserModule = import ./modules/mk-primary-user-module.nix; mkPrimaryUserModule = import ./modules/mk-primary-user-module.nix;
inherit (inputs.darwin.lib) darwinSystem; inherit (inputs.darwin.lib) darwinSystem;
inherit (inputs.nixpkgs.lib) inherit (inputs.nixpkgs.lib) attrValues makeOverridable optionalAttrs;
attrValues
makeOverridable
optionalAttrs;
# Configuration for `nixpkgs` # Configuration for `nixpkgs`
nixpkgsConfig = { nixpkgsConfig = {
@ -81,26 +73,20 @@
}; };
# helper for defining nix-darwin systems # helper for defining nix-darwin systems
mkDarwinSystem = mkDarwinSystem = { modules ? [ ], homeModules ? [ ], ... }@args:
{ modules ? [ ] import ./lib/mkDarwinSystem.nix self inputs nixpkgsConfig (args // {
, homeModules ? [ ]
, ...
}@args: import ./lib/mkDarwinSystem.nix self inputs nixpkgsConfig (args // {
inherit homeStateVersion; inherit homeStateVersion;
modules = attrValues self.darwinModules ++ modules; modules = attrValues self.darwinModules ++ modules;
homeModules = attrValues self.homeManagerModules ++ homeModules; homeModules = attrValues self.homeManagerModules ++ homeModules;
}); });
in in {
{
# `nix-darwin` configs # `nix-darwin` configs
darwinConfigurations = darwinConfigurations = let
let
bootstrap-x86 = makeOverridable darwinSystem { bootstrap-x86 = makeOverridable darwinSystem {
system = "x86_64-darwin"; system = "x86_64-darwin";
modules = [ ./darwin/bootstrap.nix { nixpkgs = nixpkgsConfig; } ]; modules = [ ./darwin/bootstrap.nix { nixpkgs = nixpkgsConfig; } ];
}; };
in in {
{
# Mininal configurations to bootstrap systems # Mininal configurations to bootstrap systems
inherit bootstrap-x86; inherit bootstrap-x86;
bootstrap-arm = bootstrap-x86.override { system = "aarch64-darwin"; }; bootstrap-arm = bootstrap-x86.override { system = "aarch64-darwin"; };
@ -111,9 +97,7 @@
modules = [{ modules = [{
networking.computerName = "matbook pro m1"; networking.computerName = "matbook pro m1";
networking.hostName = "matbook"; networking.hostName = "matbook";
networking.knownNetworkServices = [ networking.knownNetworkServices = [ "Wi-Fi" ];
"Wi-Fi"
];
nix.settings.cores = 2; nix.settings.cores = 2;
nix.settings.max-jobs = 4; nix.settings.max-jobs = 4;
@ -144,9 +128,7 @@
modules = [ modules = [
({ pkgs, lib, ... }: { ({ pkgs, lib, ... }: {
users.primaryUser = workUserInfo; users.primaryUser = workUserInfo;
networking.knownNetworkServices = [ networking.knownNetworkServices = [ "Wi-Fi" ];
"Wi-Fi"
];
nix.settings.cores = 2; nix.settings.cores = 2;
nix.settings.max-jobs = 5; nix.settings.max-jobs = 5;
@ -198,7 +180,8 @@
colors = import ./overlays/colors.nix; colors = import ./overlays/colors.nix;
# Overlay useful on Macs with Apple Silicon # Overlay useful on Macs with Apple Silicon
apple-silicon = _: prev: optionalAttrs (prev.stdenv.system == "aarch64-darwin") { apple-silicon = _: prev:
optionalAttrs (prev.stdenv.system == "aarch64-darwin") {
# Add access to x86 packages system is running Apple Silicon # Add access to x86 packages system is running Apple Silicon
pkgs-x86 = import inputs.nixpkgs { pkgs-x86 = import inputs.nixpkgs {
system = "x86_64-darwin"; system = "x86_64-darwin";
@ -206,8 +189,11 @@
}; };
}; };
homebrew-enabled = _: prev: optionalAttrs prev.stdenv.isDarwin { homebrew-enabled = _: prev:
lib = prev.lib // { homebrew-enabled = inputs.homebrew-enabled.value; }; optionalAttrs prev.stdenv.isDarwin {
lib = prev.lib // {
homebrew-enabled = inputs.homebrew-enabled.value;
};
}; };
extra-pkgs = import ./pkgs { inherit inputs; }; extra-pkgs = import ./pkgs { inherit inputs; };
@ -239,7 +225,8 @@
starship = import ./home/starship.nix; starship = import ./home/starship.nix;
starship-symbols = import ./home/starship-symbols.nix; starship-symbols = import ./home/starship-symbols.nix;
# modules # modules
programs-kakoune-extras = import ./modules/home/programs/kakoune/extras.nix; # currently unused programs-kakoune-extras =
import ./modules/home/programs/kakoune/extras.nix; # currently unused
programs-helix-extras = import ./modules/home/programs/helix/extras.nix; programs-helix-extras = import ./modules/home/programs/helix/extras.nix;
programs-kitty-extras = import ./modules/home/programs/kitty/extras.nix; programs-kitty-extras = import ./modules/home/programs/kitty/extras.nix;
home-primary-user = mkPrimaryUserModule "home"; home-primary-user = mkPrimaryUserModule "home";
@ -247,18 +234,21 @@
templates = import ./templates; templates = import ./templates;
} // flake-utils.lib.eachDefaultSystem (system: { } // flake-utils.lib.eachDefaultSystem (system: {
legacyPackages = import inputs.nixpkgs (nixpkgsConfig // { inherit system; }); legacyPackages =
import inputs.nixpkgs (nixpkgsConfig // { inherit system; });
checks.pre-commit = pre-commit.lib.${system}.run { checks.pre-commit = pre-commit.lib.${system}.run {
src = ./.; src = ./.;
hooks = { hooks = {
deadnix.enable = true; deadnix.enable = true;
nixpkgs-fmt.enable = true; nil.enable = true;
nixfmt.enable = true;
statix.enable = true; statix.enable = true;
}; };
}; };
devShells = let pkgs = self.legacyPackages.${system}; in { devShells = let pkgs = self.legacyPackages.${system};
in {
default = pkgs.mkShell { default = pkgs.mkShell {
inherit (self.checks.${system}.pre-commit) shellHook; inherit (self.checks.${system}.pre-commit) shellHook;
}; };

View File

@ -1,9 +1,7 @@
{ config, ... }: { { config, ... }: {
# Misc configuration files --------------------------------------------------------------------{{{ # Misc configuration files --------------------------------------------------------------------{{{
xdg = { xdg = { enable = true; };
enable = true;
};
home.file = { home.file = {
".pijulconfig".text = '' ".pijulconfig".text = ''

View File

@ -7,10 +7,7 @@
# Add Fish plugins # Add Fish plugins
home.packages = builtins.attrValues { home.packages = builtins.attrValues {
inherit (pkgs.fishPlugins) inherit (pkgs.fishPlugins) autopair-fish colored-man-pages done;
autopair-fish
colored-man-pages
done;
}; };
programs.fish.plugins = [ pkgs.fishPlugins.fisher ]; programs.fish.plugins = [ pkgs.fishPlugins.fisher ];
@ -136,10 +133,8 @@
# Aliases # Aliases
programs.fish.shellAliases = programs.fish.shellAliases =
let let inherit (config.home.primaryUser) nixConfigDirectory;
inherit (config.home.primaryUser) nixConfigDirectory; in {
in
{
# Nix related # Nix related
from-nix = "from-dir ${nixConfigDirectory}"; from-nix = "from-dir ${nixConfigDirectory}";
# darwin-rebuild build # darwin-rebuild build
@ -147,7 +142,8 @@
# darwin-rebuild switch full # darwin-rebuild switch full
drsf = "from-nix darwin-rebuild switch --flake ."; drsf = "from-nix darwin-rebuild switch --flake .";
# darwin-rebuild switch (no homebrew) # darwin-rebuild switch (no homebrew)
drs = "from-nix darwin-rebuild switch --flake . --override-input homebrew-enabled github:boolean-option/false"; drs =
"from-nix darwin-rebuild switch --flake . --override-input homebrew-enabled github:boolean-option/false";
# edit darwin-rebuild config in code/codium # edit darwin-rebuild config in code/codium
drc = "code ${nixConfigDirectory}"; drc = "code ${nixConfigDirectory}";
# edit darwin-rebuild config in vim # edit darwin-rebuild config in vim
@ -164,7 +160,8 @@
nsh = "nix shell"; nsh = "nix shell";
nshu = "nix-unfree shell"; nshu = "nix-unfree shell";
nrp = "nix repl --expr '{ pkgs = (import <nixpkgs> { }); }'"; nrp = "nix repl --expr '{ pkgs = (import <nixpkgs> { }); }'";
nrpu = "nix repl --expr '{ pkgs = (import <nixpkgs> { config.allowUnfree = true; }); }' --impure"; nrpu =
"nix repl --expr '{ pkgs = (import <nixpkgs> { config.allowUnfree = true; }); }' --impure";
# Other # Other
".." = "cd .."; ".." = "cd ..";
@ -183,7 +180,8 @@
colortest = "${pkgs.terminal-colors}/bin/terminal-colors -o"; colortest = "${pkgs.terminal-colors}/bin/terminal-colors -o";
} // lib.optionalAttrs pkgs.stdenv.isDarwin { } // lib.optionalAttrs pkgs.stdenv.isDarwin {
sb = "set-background-to-macOS"; sb = "set-background-to-macOS";
conda-init = "eval /opt/homebrew/bin/conda 'shell.fish' 'hook' $argv | source"; conda-init =
"eval /opt/homebrew/bin/conda 'shell.fish' 'hook' $argv | source";
}; };
# Configuration that should be above `loginShellInit` and `interactiveShellInit`. # Configuration that should be above `loginShellInit` and `interactiveShellInit`.

View File

@ -17,10 +17,7 @@
help.autocorrect = "prompt"; help.autocorrect = "prompt";
}; };
programs.git.ignores = [ programs.git.ignores = [ ".DS_Store" ".direnv" ];
".DS_Store"
".direnv"
];
# Enhanced diffs # Enhanced diffs
programs.git.delta.enable = true; programs.git.delta.enable = true;

View File

@ -31,7 +31,5 @@
dark = "rose_pine"; dark = "rose_pine";
}; };
home.sessionVariables = { home.sessionVariables = { EDITOR = "hx"; };
EDITOR = "hx";
};
} }

View File

@ -1,17 +1,11 @@
{ pkgs, ... }: { pkgs, ... }:
# Let-In --------------------------------------------------------------------------------------- {{{ # Let-In --------------------------------------------------------------------------------------- {{{
let let
colorsToKitty = colors: with colors; { colorsToKitty = colors:
inherit with colors; {
background inherit background foreground selection_background selection_foreground
foreground tab_bar_background active_tab_background active_tab_foreground
selection_background inactive_tab_background inactive_tab_foreground;
selection_foreground
tab_bar_background
active_tab_background
active_tab_foreground
inactive_tab_background
inactive_tab_foreground;
cursor = white; cursor = white;
cursor_text_color = background; cursor_text_color = background;
color0 = black; color0 = black;
@ -33,9 +27,8 @@ let
url_color = brightgreen; url_color = brightgreen;
}; };
font = "Rec Mono Duotone"; font = "Rec Mono Duotone";
in
# }}} # }}}
{ in {
# Kitty terminal # Kitty terminal
# https://sw.kovidgoyal.net/kitty/conf.html # https://sw.kovidgoyal.net/kitty/conf.html
# https://rycee.gitlab.io/home-manager/options.html#opt-programs.kitty.enable # https://rycee.gitlab.io/home-manager/options.html#opt-programs.kitty.enable

View File

@ -5,9 +5,7 @@
# https://rycee.gitlab.io/home-manager/options.html#opt-programs.bat.enable # https://rycee.gitlab.io/home-manager/options.html#opt-programs.bat.enable
bat = { bat = {
enable = true; enable = true;
config = { config = { style = "auto"; };
style = "auto";
};
}; };
# Direnv, load and unload environment variables depending on the current directory. # Direnv, load and unload environment variables depending on the current directory.
# https://direnv.net # https://direnv.net
@ -16,12 +14,8 @@
enable = true; enable = true;
nix-direnv.enable = true; nix-direnv.enable = true;
}; };
nix-index = { nix-index = { enable = true; };
enable = true; nushell = { enable = true; };
};
nushell = {
enable = true;
};
ssh = { ssh = {
enable = true; enable = true;
matchBlocks."*".extraOptions = lib.optionalAttrs pkgs.stdenv.isDarwin { matchBlocks."*".extraOptions = lib.optionalAttrs pkgs.stdenv.isDarwin {
@ -33,9 +27,7 @@
# enable = true; # enable = true;
# extensions = [ pijul-vscode ]; # extensions = [ pijul-vscode ];
# }; # };
zoxide = { zoxide = { enable = true; };
enable = true;
};
}; };
# }}} # }}}
@ -44,21 +36,16 @@
home.packages = builtins.attrValues ({ home.packages = builtins.attrValues ({
inherit (pkgs) inherit (pkgs)
# GUI apps # GUI apps
cinny cinny discord-ptb lagrange obsidian slack zoom-us
discord-ptb
lagrange
obsidian
slack
zoom-us
# System # System
curl wget
# lightweight session management # lightweight session management
abduco abduco
# archive tool # archive tool
atool atool
# fancy version of `top` with ASCII graphs # fancy version of `top` with ASCII graphs
bottom bottom
curl
# fancy version of `du` # fancy version of `du`
du-dust du-dust
# fancy version of `ls` # fancy version of `ls`
@ -79,7 +66,6 @@
thefuck thefuck
# extract RAR archives # extract RAR archives
unrar unrar
wget
# extract XZ archives # extract XZ archives
xz xz
@ -106,23 +92,19 @@
xh xh
# Useful nix related tools # Useful nix related tools
nixfmt nix-prefetch-git nix-tree
# adding/managing alternative binary caches hosted by Cachix # adding/managing alternative binary caches hosted by Cachix
cachix cachix
# run software from nixpkgs without installing it # run software from nixpkgs without installing it
comma comma
nixpkgs-fmt
nix-prefetch-git
nix-tree
# nix language server # nix language server
nil nil;
;
} // lib.optionalAttrs pkgs.stdenv.isDarwin { } // lib.optionalAttrs pkgs.stdenv.isDarwin {
inherit (pkgs) inherit (pkgs)
# useful macOS CLI commands # useful macOS CLI commands
m-cli m-cli
# see /overlays/colors.nix # see /overlays/colors.nix
is-dark-mode is-dark-mode;
;
}); });
# }}} # }}}
} }

View File

@ -2,8 +2,8 @@
# dark-mode-notify configuration # dark-mode-notify configuration
# {{{ # {{{
launchd.agents.dark-mode-notify = launchd.agents.dark-mode-notify =
let logPath = "${config.xdg.stateHome}/dark-mode-notify"; in let logPath = "${config.xdg.stateHome}/dark-mode-notify";
{ in {
enable = true; enable = true;
config = { config = {
Label = "ke.bou.dark-mode-notify"; Label = "ke.bou.dark-mode-notify";

View File

@ -1,8 +1,7 @@
{ config, pkgs, ... }: { { config, pkgs, ... }: {
# tarsnap periodic backup configuration # tarsnap periodic backup configuration
# {{{ # {{{
launchd.agents.tarsnap = launchd.agents.tarsnap = let
let
logPath = "${config.xdg.stateHome}/tarsnap"; logPath = "${config.xdg.stateHome}/tarsnap";
tarsnapBackup = pkgs.writeShellScriptBin "tarsnap-backup-helper" '' tarsnapBackup = pkgs.writeShellScriptBin "tarsnap-backup-helper" ''
date=$(date -u +%Y-%m-%dT%H:%M:%SZ) date=$(date -u +%Y-%m-%dT%H:%M:%SZ)
@ -14,8 +13,7 @@
-f $(uname -n)-$date \ -f $(uname -n)-$date \
${config.home.homeDirectory}/{dotfiles.nix,Desktop,Development,Documents,Downloads} ${config.home.homeDirectory}/{dotfiles.nix,Desktop,Development,Documents,Downloads}
''; '';
in in {
{
enable = true; enable = true;
config = { config = {
Label = "com.tarsnap.tarsnap"; Label = "com.tarsnap.tarsnap";
@ -43,6 +41,3 @@
# }}} # }}}
} }

View File

@ -1,6 +1,6 @@
{ lib, ... }: { lib, ... }:
let inherit (lib) mkDefault; in let inherit (lib) mkDefault;
{ in {
programs.starship.settings = { programs.starship.settings = {
aws.symbol = mkDefault " "; aws.symbol = mkDefault " ";
battery.full_symbol = mkDefault ""; battery.full_symbol = mkDefault "";

View File

@ -9,12 +9,14 @@
# See docs here: https://starship.rs/config/ # See docs here: https://starship.rs/config/
# Symbols config configured in Flake. # Symbols config configured in Flake.
battery.display = [ battery.display = [{
{ threshold = 25; } # display battery information if charge is <= 25% threshold = 25;
} # display battery information if charge is <= 25%
]; ];
directory.fish_style_pwd_dir_length = 1; # turn on fish directory truncation directory.fish_style_pwd_dir_length = 1; # turn on fish directory truncation
directory.truncation_length = 2; # number of directories not to truncate directory.truncation_length = 2; # number of directories not to truncate
memory_usage.disabled = true; # because it includes cached memory it's reported as full a lot memory_usage.disabled =
true; # because it includes cached memory it's reported as full a lot
}; };
# }}} # }}}
} }

View File

@ -1,8 +1,7 @@
# taken from https://github.com/malob/nixpkgs/blob/27e04346555277687a60c0168969b3945c2b25ba/lib/mkDarwinSystem.nix # taken from https://github.com/malob/nixpkgs/blob/27e04346555277687a60c0168969b3945c2b25ba/lib/mkDarwinSystem.nix
self: inputs: nixpkgs: self: inputs: nixpkgs:
{ primaryUser { primaryUser, system ? "aarch64-darwin"
, system ? "aarch64-darwin"
# `nix-darwin` modules to include # `nix-darwin` modules to include
, modules ? [ ] , modules ? [ ]
@ -16,16 +15,15 @@ self: inputs: nixpkgs:
, homeModules ? [ ] , homeModules ? [ ]
# Additional `home-manager` modules to include, useful when reusing a configuration with # Additional `home-manager` modules to include, useful when reusing a configuration with
# `lib.makeOverridable`. # `lib.makeOverridable`.
, extraHomeModules ? [ ] , extraHomeModules ? [ ] }:
}:
inputs.darwin.lib.darwinSystem { inputs.darwin.lib.darwinSystem {
inherit system; inherit system;
modules = modules ++ extraModules ++ [ modules = modules ++ extraModules ++ [
inputs.home-manager.darwinModules.home-manager inputs.home-manager.darwinModules.home-manager
({ config, ... }: ({ config, ... }:
let cfg = config.users.primaryUser; in let cfg = config.users.primaryUser;
{ in {
users.primaryUser = primaryUser; users.primaryUser = primaryUser;
inherit nixpkgs; inherit nixpkgs;

View File

@ -5,10 +5,10 @@ let
inherit (cfg) extras; inherit (cfg) extras;
tomlFormat = pkgs.formats.toml { }; tomlFormat = pkgs.formats.toml { };
inherit (lib) mkIf mkEnableOption mkOption types; inherit (lib) mkIf mkEnableOption mkOption types;
in in {
{
options.programs.helix.extras = { options.programs.helix.extras = {
autoTheme.enable = mkEnableOption "Automatically switch helix theme with night mode"; autoTheme.enable =
mkEnableOption "Automatically switch helix theme with night mode";
autoTheme.light = mkOption { autoTheme.light = mkOption {
type = types.str; type = types.str;
@ -23,14 +23,17 @@ in
config = mkIf (cfg.enable && extras.autoTheme.enable) { config = mkIf (cfg.enable && extras.autoTheme.enable) {
xdg.configFile = { xdg.configFile = {
"helix/light.toml".source = tomlFormat.generate "helix-autotheme" (cfg.settings // { theme = extras.autoTheme.light; }); "helix/light.toml".source = tomlFormat.generate "helix-autotheme"
"helix/dark.toml".source = tomlFormat.generate "helix-autotheme" (cfg.settings // { theme = extras.autoTheme.dark; }); (cfg.settings // { theme = extras.autoTheme.light; });
"helix/dark.toml".source = tomlFormat.generate "helix-autotheme"
(cfg.settings // { theme = extras.autoTheme.dark; });
}; };
programs.fish.functions = { programs.fish.functions = {
hx = { hx = {
wraps = "hx"; wraps = "hx";
description = "Helix invocation wrapper to automatically select the right theme"; description =
"Helix invocation wrapper to automatically select the right theme";
body = '' body = ''
if is-dark-mode if is-dark-mode
command hx --config ${config.xdg.configHome}/helix/dark.toml $argv command hx --config ${config.xdg.configHome}/helix/dark.toml $argv

View File

@ -9,24 +9,24 @@ let
makeKakouneFace = face: name: makeKakouneFace = face: name:
let let
mkColor = name: mkColor = name:
if hasPrefix "#" name if hasPrefix "#" name then
then "rgb:${substring 1 (-1) name}" "rgb:${substring 1 (-1) name}"
else if hasPrefix "!#" name else if hasPrefix "!#" name then
then "rgba:${substring 2 (-1) name}" "rgba:${substring 2 (-1) name}"
else name; else
value = name;
if isList name value = if isList name then
then concatStringsSep "," (map mkColor name) concatStringsSep "," (map mkColor name)
else mkColor name; else
in mkColor name;
"face global ${face} ${value}"; in "face global ${face} ${value}";
makeKakouneColors = faces: makeKakouneColors = faces:
concatStringsSep "\n" concatStringsSep "\n"
([ "# Generated by home-manager" ] ([ "# Generated by home-manager" ] ++ mapAttrsToList makeKakouneFace faces);
++ mapAttrsToList makeKakouneFace faces);
writeKakouneConfig = file: config: pkgs.writeText file (makeKakouneColors config); writeKakouneConfig = file: config:
pkgs.writeText file (makeKakouneColors config);
kakoune-colors = { kakoune-colors = {
light = writeKakouneConfig "light.kak" cfg.colors.light; light = writeKakouneConfig "light.kak" cfg.colors.light;
@ -44,8 +44,7 @@ let
kak-dark = pkgs.writeShellScriptBin "kak-dark" '' kak-dark = pkgs.writeShellScriptBin "kak-dark" ''
${kak-background}/bin/kak-background dark ${kak-background}/bin/kak-background dark
''; '';
in in {
{
options.programs.kakoune.extras = { options.programs.kakoune.extras = {
colors = { colors = {
enable = mkEnableOption "Custom kakoune color handling"; enable = mkEnableOption "Custom kakoune color handling";
@ -63,11 +62,8 @@ in
}; };
config = mkIf config.programs.kakoune.enable { config = mkIf config.programs.kakoune.enable {
home.packages = mkIf cfg.colors.enable [ home.packages =
kak-light mkIf cfg.colors.enable [ kak-light kak-dark kak-background ];
kak-dark
kak-background
];
xdg.configFile."kak/colors/light.kak".source = kakoune-colors.light; xdg.configFile."kak/colors/light.kak".source = kakoune-colors.light;
xdg.configFile."kak/colors/dark.kak".source = kakoune-colors.dark; xdg.configFile."kak/colors/dark.kak".source = kakoune-colors.dark;

View File

@ -7,10 +7,12 @@ let
cfg = config.programs.kitty.extras; cfg = config.programs.kitty.extras;
# Create a Kitty config string from a Nix set # Create a Kitty config string from a Nix set
setToKittyConfig = with generators; toKeyValue { mkKeyValue = mkKeyValueDefault { } " "; }; setToKittyConfig = with generators;
toKeyValue { mkKeyValue = mkKeyValueDefault { } " "; };
# Write a Nix set representing a kitty config into the Nix store # Write a Nix set representing a kitty config into the Nix store
writeKittyConfig = fileName: config: pkgs.writeTextDir "${fileName}" (setToKittyConfig config); writeKittyConfig = fileName: config:
pkgs.writeTextDir "${fileName}" (setToKittyConfig config);
# Path in Nix store containing light and dark kitty color configs # Path in Nix store containing light and dark kitty color configs
kitty-colors = pkgs.symlinkJoin { kitty-colors = pkgs.symlinkJoin {
@ -36,8 +38,7 @@ let
term-dark = pkgs.writeShellScriptBin "term-dark" '' term-dark = pkgs.writeShellScriptBin "term-dark" ''
${term-background}/bin/term-background ${cfg.colors.dark-name} ${term-background}/bin/term-background ${cfg.colors.dark-name}
''; '';
in in {
{
options.programs.kitty.extras = { options.programs.kitty.extras = {
colors = { colors = {
@ -112,13 +113,13 @@ in
appPath = mkOption { appPath = mkOption {
type = types.str; type = types.str;
default = null; default = null;
description = ''Path to kitty.app''; description = "Path to kitty.app";
}; };
iconPath = mkOption { iconPath = mkOption {
type = types.str; type = types.str;
default = null; default = null;
description = ''Path to kitty icns''; description = "Path to kitty icns";
}; };
}; };
@ -126,18 +127,13 @@ in
config = mkIf config.programs.kitty.enable { config = mkIf config.programs.kitty.enable {
home.packages = mkIf cfg.colors.enable [ home.packages =
term-light mkIf cfg.colors.enable [ term-light term-dark term-background ];
term-dark
term-background
];
home.activation = home.activation = let fileicon = "/opt/homebrew/bin/fileicon";
let in mkIf (pkgs.stdenv.isDarwin && cfg.fixIcon.enable) {
fileicon = "/opt/homebrew/bin/fileicon"; cleanupKittyIcon =
in lib.hm.dag.entryBetween [ "darwinApps" ] [ "writeBoundary" ] ''
mkIf (pkgs.stdenv.isDarwin && cfg.fixIcon.enable) {
cleanupKittyIcon = lib.hm.dag.entryBetween [ "darwinApps" ] [ "writeBoundary" ] ''
if ${fileicon} test ${cfg.fixIcon.appPath}; if ${fileicon} test ${cfg.fixIcon.appPath};
then then
$DRY_RUN_CMD sudo ${fileicon} rm ${cfg.fixIcon.appPath} $DRY_RUN_CMD sudo ${fileicon} rm ${cfg.fixIcon.appPath}
@ -148,19 +144,21 @@ in
''; '';
}; };
programs.kitty.settings = optionalAttrs cfg.colors.enable programs.kitty.settings = optionalAttrs cfg.colors.enable {
{
allow_remote_control = "yes"; allow_remote_control = "yes";
listen_on = "unix:/tmp/mykitty"; listen_on = "unix:/tmp/mykitty";
} // optionalAttrs (cfg.useSymbolsFromNerdFont != "") { } // optionalAttrs (cfg.useSymbolsFromNerdFont != "") {
# https://github.com/ryanoasis/nerd-fonts/wiki/Glyph-Sets-and-Code-Points # https://github.com/ryanoasis/nerd-fonts/wiki/Glyph-Sets-and-Code-Points
symbol_map = "U+E5FA-U+E62B,U+E700-U+E7C5,U+F000-U+F2E0,U+E200-U+E2A9,U+F500-U+FD46,U+E300-U+E3EB,U+F400-U+F4A8,U+2665,U+26a1,U+F27C,U+E0A3,U+E0B4-U+E0C8,U+E0CA,U+E0CC-U+E0D2,U+E0D4,U+23FB-U+23FE,U+2B58,U+F300-U+F313,U+E000-U+E00D ${cfg.useSymbolsFromNerdFont}"; symbol_map =
"U+E5FA-U+E62B,U+E700-U+E7C5,U+F000-U+F2E0,U+E200-U+E2A9,U+F500-U+FD46,U+E300-U+E3EB,U+F400-U+F4A8,U+2665,U+26a1,U+F27C,U+E0A3,U+E0B4-U+E0C8,U+E0CA,U+E0CC-U+E0D2,U+E0D4,U+23FB-U+23FE,U+2B58,U+F300-U+F313,U+E000-U+E00D ${cfg.useSymbolsFromNerdFont}";
}; };
xdg.configFile."kitty/macos-launch-services-cmdline" = xdg.configFile."kitty/macos-launch-services-cmdline" =
mkIf (pkgs.stdenv.isDarwin && cfg.colors.enable) { text = "--listen-on unix:/tmp/mykitty"; }; mkIf (pkgs.stdenv.isDarwin && cfg.colors.enable) {
text = "--listen-on unix:/tmp/mykitty";
};
}; };

View File

@ -1,20 +1,19 @@
optionName: { config, lib, pkgs, ... }: optionName:
{ config, lib, pkgs, ... }:
let let
inherit (lib) mkOption types; inherit (lib) mkOption types;
inherit (pkgs.stdenv) isDarwin; inherit (pkgs.stdenv) isDarwin;
cfg = config.${optionName}.primaryUser; cfg = config.${optionName}.primaryUser;
in
{ in {
options.${optionName}.primaryUser = { options.${optionName}.primaryUser = {
username = mkOption { type = types.str; }; username = mkOption { type = types.str; };
fullName = mkOption { type = types.str; }; fullName = mkOption { type = types.str; };
email = mkOption { type = types.str; }; email = mkOption { type = types.str; };
homeDirectory = mkOption { homeDirectory = mkOption {
type = types.str; type = types.str;
default = default = let prefix = if isDarwin then "/Users" else "/home";
let prefix = if isDarwin then "/Users" else "/home";
in "${prefix}/${cfg.username}"; in "${prefix}/${cfg.username}";
}; };
nixConfigDirectory = mkOption { nixConfigDirectory = mkOption {

View File

@ -1,8 +1,6 @@
_final: prev: { _final: prev: {
lib = prev.lib // { lib = prev.lib // {
colors = { colors = { tokyonight = import ./colors/tokyonight.nix; };
tokyonight = import ./colors/tokyonight.nix;
};
}; };
is-dark-mode = prev.writeShellScriptBin "is-dark-mode" '' is-dark-mode = prev.writeShellScriptBin "is-dark-mode" ''
defaults read -g AppleInterfaceStyle &>/dev/null defaults read -g AppleInterfaceStyle &>/dev/null

View File

@ -5,7 +5,8 @@ stdenv.mkDerivation {
pname = "cinny"; pname = "cinny";
nativeBuildInputs = [ undmg unzip ]; nativeBuildInputs = [ undmg unzip ];
src = fetchurl { src = fetchurl {
url = "https://github.com/cinnyapp/cinny-desktop/releases/download/v${version}/Cinny_desktop-x86_64.dmg"; url =
"https://github.com/cinnyapp/cinny-desktop/releases/download/v${version}/Cinny_desktop-x86_64.dmg";
sha256 = "sha256-m8sYA7YjvhqGFuU1L1y7BtndHGd6MpuH+hKzPSukxD0="; sha256 = "sha256-m8sYA7YjvhqGFuU1L1y7BtndHGd6MpuH+hKzPSukxD0=";
}; };

View File

@ -1,17 +1,10 @@
{ stdenv { stdenv, lib, xcodeenv, dark-mode-notify-src, sdkVersion, ... }:
, lib
, xcodeenv
, dark-mode-notify-src
, sdkVersion
, ...
}:
let let
xcode = xcodeenv.composeXcodeWrapper { xcode = xcodeenv.composeXcodeWrapper {
version = sdkVersion; version = sdkVersion;
xcodeBaseDir = "/Applications/Xcode.app"; xcodeBaseDir = "/Applications/Xcode.app";
}; };
in in stdenv.mkDerivation {
stdenv.mkDerivation {
name = "dark-mode-notify"; name = "dark-mode-notify";
src = dark-mode-notify-src; src = dark-mode-notify-src;
buildPhase = '' buildPhase = ''

View File

@ -1,5 +1,6 @@
{ inputs }: { inputs }:
_: prev: { _: prev:
{
inherit (inputs) kitty-icon kitty-themes; inherit (inputs) kitty-icon kitty-themes;
fishPlugins = prev.fishPlugins // { fishPlugins = prev.fishPlugins // {
fisher = { fisher = {
@ -8,16 +9,11 @@ _: prev: {
}; };
}; };
helix = inputs.helix.packages.${prev.stdenv.system}.default; helix = inputs.helix.packages.${prev.stdenv.system}.default;
} // builtins.mapAttrs } // builtins.mapAttrs (name: extras:
(name: extras: prev.callPackage (./. + "/${name}.nix")
prev.callPackage ({ "${name}-src" = inputs."${name}-src"; } // extras)) {
(./. + "/${name}.nix")
({ "${name}-src" = inputs."${name}-src"; } // extras))
{
cinny = { }; cinny = { };
dark-mode-notify = { dark-mode-notify = { sdkVersion = "14.*"; };
sdkVersion = "14.*";
};
ia-writer-family = { }; ia-writer-family = { };
yubiswitch = { }; yubiswitch = { };
} }

View File

@ -1,9 +1,7 @@
{ ia-writer-family-src, lib, stdenv }: { ia-writer-family-src, lib, stdenv }:
let let version = "20181224";
version = "20181224"; in stdenv.mkDerivation {
in
stdenv.mkDerivation {
name = "ia-writer-family-${version}"; name = "ia-writer-family-${version}";
src = ia-writer-family-src; src = ia-writer-family-src;

View File

@ -5,7 +5,8 @@ stdenv.mkDerivation {
pname = "yubiswitch"; pname = "yubiswitch";
nativeBuildInputs = [ undmg unzip ]; nativeBuildInputs = [ undmg unzip ];
src = fetchurl { src = fetchurl {
url = "https://github.com/pallotron/yubiswitch/releases/download/v${version}/yubiswitch_${version}.dmg"; url =
"https://github.com/pallotron/yubiswitch/releases/download/v${version}/yubiswitch_${version}.dmg";
sha256 = "aR/3AXwAAhFYchfGCmqfNSs8uNnuLOCZ8B0JbXlKAf8="; sha256 = "aR/3AXwAAhFYchfGCmqfNSs8uNnuLOCZ8B0JbXlKAf8=";
}; };

View File

@ -1,7 +1,7 @@
let let
mkTemplates = builtins.mapAttrs (name: attrs: attrs // { path = ./. + "/${name}"; }); mkTemplates =
in builtins.mapAttrs (name: attrs: attrs // { path = ./. + "/${name}"; });
mkTemplates { in mkTemplates {
rust = { rust = {
description = "A rust flake template based on flake.parts"; description = "A rust flake template based on flake.parts";
welcomeText = '' welcomeText = ''

View File

@ -13,21 +13,17 @@
outputs = inputs@{ self, flake-parts, crane, pre-commit, ... }: outputs = inputs@{ self, flake-parts, crane, pre-commit, ... }:
flake-parts.lib.mkFlake { inherit inputs; } { flake-parts.lib.mkFlake { inherit inputs; } {
imports = [ pre-commit.flakeModule ]; imports = [ pre-commit.flakeModule ];
systems = [ systems =
"aarch64-darwin" [ "aarch64-darwin" "aarch64-linux" "x86_64-darwin" "x86_64-linux" ];
"aarch64-linux"
"x86_64-darwin"
"x86_64-linux"
];
perSystem = { config, pkgs, system, ... }: perSystem = { config, pkgs, system, ... }:
let let
crane-lib = crane.lib.${system}; crane-lib = crane.lib.${system};
package = crane-lib.buildPackage { package = crane-lib.buildPackage {
src = crane-lib.cleanCargoSource ./.; src = crane-lib.cleanCargoSource ./.;
nativeBuildInputs = pkgs.lib.optionals pkgs.stdenv.isDarwin [ pkgs.libiconv ]; nativeBuildInputs =
pkgs.lib.optionals pkgs.stdenv.isDarwin [ pkgs.libiconv ];
}; };
in in {
{
pre-commit.settings.hooks = { pre-commit.settings.hooks = {
rustfmt.enable = true; rustfmt.enable = true;
clippy.enable = true; clippy.enable = true;
@ -42,19 +38,12 @@
''; '';
inputsFrom = builtins.attrValues self.checks; inputsFrom = builtins.attrValues self.checks;
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; RUST_SRC_PATH =
nativeBuildInputs = builtins.attrValues { "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
inherit (pkgs) nativeBuildInputs =
cargo builtins.attrValues { inherit (pkgs) cargo rustc; };
rustc
;
};
buildInputs = builtins.attrValues { buildInputs = builtins.attrValues {
inherit (pkgs) inherit (pkgs) rust-analyzer rustfmt clippy;
rust-analyzer
rustfmt
clippy
;
}; };
}; };
}; };