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.settings = {
@ -20,14 +19,15 @@
"pre-commit-hooks.cachix.org-1:Pkk3Panw5AW24TOv6kz3PvLhlH8puAsJTBbOPmBo7Rc="
"iohk.cachix.org-1:DpRUyj7h7V830dp/i6Nti+NEO2/nhblbov/8MW7Rqoo="
];
trusted-users = [
"@admin"
];
trusted-users = [ "@admin" ];
# TODO: remove and replace with a launchd job
# see https://github.com/NixOS/nix/issues/7273
auto-optimise-store = true;
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;
@ -35,12 +35,8 @@
services.nix-daemon.enable = true;
# Make Fish the default shell
environment.shells = lib.mkForce (builtins.attrValues {
inherit (pkgs)
bashInteractive
fish
zsh;
});
environment.shells = lib.mkForce
(builtins.attrValues { inherit (pkgs) bashInteractive fish zsh; });
programs.fish.enable = true;
programs.fish.useBabelfish = true;

View File

@ -2,8 +2,7 @@
let
inherit (config.users) primaryUser;
caskPresent = cask: lib.any (x: x.name == cask) config.homebrew.casks;
in
{
in {
environment.shellInit = ''
eval "$(${config.homebrew.brewPrefix}/brew shellenv)"
'';
@ -87,19 +86,16 @@ in
# "zoom"
];
home-manager.users.${primaryUser.username} =
let
socket = "${primaryUser.homeDirectory}/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh";
in
lib.mkIf (caskPresent "secretive" && config ? home-manager) {
home.sessionVariables.SSH_AUTH_SOCK = socket;
programs.ssh = {
enable = true;
matchBlocks."*".extraOptions = {
IdentityAgent = socket;
};
};
home-manager.users.${primaryUser.username} = let
socket =
"${primaryUser.homeDirectory}/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh";
in lib.mkIf (caskPresent "secretive" && config ? home-manager) {
home.sessionVariables.SSH_AUTH_SOCK = socket;
programs.ssh = {
enable = true;
matchBlocks."*".extraOptions = { IdentityAgent = socket; };
};
};
# For cli packages that aren't currently available for macOS in `nixpkgs`.Packages should be
# installed in `../home/programs.nix` whenever possible.

View File

@ -1,14 +1,7 @@
# See https://nixos.wiki/wiki/Flakes#Using_flakes_project_from_a_legacy_Nix
(import
(
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
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;
}
)
{
src = ./.;
}).defaultNix
(import (let lock = builtins.fromJSON (builtins.readFile ./flake.lock);
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;
}) { src = ./.; }).defaultNix

200
flake.nix
View File

@ -42,12 +42,7 @@
starship-src.flake = false;
};
outputs =
{ self
, flake-utils
, pre-commit
, ...
}@inputs:
outputs = { self, flake-utils, pre-commit, ... }@inputs:
let
# this is a "functor" that takes an option name
# this allows for creating identical modules
@ -55,10 +50,7 @@
mkPrimaryUserModule = import ./modules/mk-primary-user-module.nix;
inherit (inputs.darwin.lib) darwinSystem;
inherit (inputs.nixpkgs.lib)
attrValues
makeOverridable
optionalAttrs;
inherit (inputs.nixpkgs.lib) attrValues makeOverridable optionalAttrs;
# Configuration for `nixpkgs`
nixpkgsConfig = {
@ -81,94 +73,84 @@
};
# helper for defining nix-darwin systems
mkDarwinSystem =
{ modules ? [ ]
, homeModules ? [ ]
, ...
}@args: import ./lib/mkDarwinSystem.nix self inputs nixpkgsConfig (args // {
mkDarwinSystem = { modules ? [ ], homeModules ? [ ], ... }@args:
import ./lib/mkDarwinSystem.nix self inputs nixpkgsConfig (args // {
inherit homeStateVersion;
modules = attrValues self.darwinModules ++ modules;
homeModules = attrValues self.homeManagerModules ++ homeModules;
});
in
{
in {
# `nix-darwin` configs
darwinConfigurations =
let
bootstrap-x86 = makeOverridable darwinSystem {
system = "x86_64-darwin";
modules = [ ./darwin/bootstrap.nix { nixpkgs = nixpkgsConfig; } ];
};
in
{
# Mininal configurations to bootstrap systems
inherit bootstrap-x86;
bootstrap-arm = bootstrap-x86.override { system = "aarch64-darwin"; };
# M1 MBP
matbook = mkDarwinSystem {
primaryUser = primaryUserInfo;
modules = [{
networking.computerName = "matbook pro m1";
networking.hostName = "matbook";
networking.knownNetworkServices = [
"Wi-Fi"
];
nix.settings.cores = 2;
nix.settings.max-jobs = 4;
homebrew.casks = [
# games
"gog-galaxy"
"origin"
"sony-ps-remote-play"
"steam"
];
home-manager.sharedModules = [{
# programs.fish.shellAliases = {
# code = "${pkgs.vscodium}/bin/codium";
# };
programs.ssh.matchBlocks.remarkable = {
hostname = "10.11.99.1";
user = "root";
port = 22;
};
# programs.vscode.package = pkgs.vscodium;
programs.vscode.enable = true;
}];
}];
};
yelpbook-m1 = mkDarwinSystem {
primaryUser = workUserInfo;
modules = [
({ pkgs, lib, ... }: {
users.primaryUser = workUserInfo;
networking.knownNetworkServices = [
"Wi-Fi"
];
nix.settings.cores = 2;
nix.settings.max-jobs = 5;
homebrew.casks = [ "itsycal" ];
home-manager.sharedModules = [{
# TODO: how to remove this entirely?
home.file.".tarsnaprc" = lib.mkForce { text = ""; };
home.packages = [ pkgs.yubiswitch ];
programs.ssh.matchBlocks.devbox = {
hostname = "csdev6";
forwardAgent = true;
serverAliveInterval = 120;
};
programs.fish.functions.devbox.body = ''
ssh -t devbox "agenttmux attach; or agenttmux new -s yelp"
'';
launchd.agents.tarsnap.enable = lib.mkForce false;
}];
})
];
};
darwinConfigurations = let
bootstrap-x86 = makeOverridable darwinSystem {
system = "x86_64-darwin";
modules = [ ./darwin/bootstrap.nix { nixpkgs = nixpkgsConfig; } ];
};
in {
# Mininal configurations to bootstrap systems
inherit bootstrap-x86;
bootstrap-arm = bootstrap-x86.override { system = "aarch64-darwin"; };
# M1 MBP
matbook = mkDarwinSystem {
primaryUser = primaryUserInfo;
modules = [{
networking.computerName = "matbook pro m1";
networking.hostName = "matbook";
networking.knownNetworkServices = [ "Wi-Fi" ];
nix.settings.cores = 2;
nix.settings.max-jobs = 4;
homebrew.casks = [
# games
"gog-galaxy"
"origin"
"sony-ps-remote-play"
"steam"
];
home-manager.sharedModules = [{
# programs.fish.shellAliases = {
# code = "${pkgs.vscodium}/bin/codium";
# };
programs.ssh.matchBlocks.remarkable = {
hostname = "10.11.99.1";
user = "root";
port = 22;
};
# programs.vscode.package = pkgs.vscodium;
programs.vscode.enable = true;
}];
}];
};
yelpbook-m1 = mkDarwinSystem {
primaryUser = workUserInfo;
modules = [
({ pkgs, lib, ... }: {
users.primaryUser = workUserInfo;
networking.knownNetworkServices = [ "Wi-Fi" ];
nix.settings.cores = 2;
nix.settings.max-jobs = 5;
homebrew.casks = [ "itsycal" ];
home-manager.sharedModules = [{
# TODO: how to remove this entirely?
home.file.".tarsnaprc" = lib.mkForce { text = ""; };
home.packages = [ pkgs.yubiswitch ];
programs.ssh.matchBlocks.devbox = {
hostname = "csdev6";
forwardAgent = true;
serverAliveInterval = 120;
};
programs.fish.functions.devbox.body = ''
ssh -t devbox "agenttmux attach; or agenttmux new -s yelp"
'';
launchd.agents.tarsnap.enable = lib.mkForce false;
}];
})
];
};
};
# Overlays --------------------------------------------------------------- {{{
@ -198,17 +180,21 @@
colors = import ./overlays/colors.nix;
# Overlay useful on Macs with Apple Silicon
apple-silicon = _: prev: optionalAttrs (prev.stdenv.system == "aarch64-darwin") {
# Add access to x86 packages system is running Apple Silicon
pkgs-x86 = import inputs.nixpkgs {
system = "x86_64-darwin";
inherit (nixpkgsConfig) config;
apple-silicon = _: prev:
optionalAttrs (prev.stdenv.system == "aarch64-darwin") {
# Add access to x86 packages system is running Apple Silicon
pkgs-x86 = import inputs.nixpkgs {
system = "x86_64-darwin";
inherit (nixpkgsConfig) config;
};
};
};
homebrew-enabled = _: prev: optionalAttrs prev.stdenv.isDarwin {
lib = prev.lib // { homebrew-enabled = inputs.homebrew-enabled.value; };
};
homebrew-enabled = _: prev:
optionalAttrs prev.stdenv.isDarwin {
lib = prev.lib // {
homebrew-enabled = inputs.homebrew-enabled.value;
};
};
extra-pkgs = import ./pkgs { inherit inputs; };
};
@ -239,7 +225,8 @@
starship = import ./home/starship.nix;
starship-symbols = import ./home/starship-symbols.nix;
# 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-kitty-extras = import ./modules/home/programs/kitty/extras.nix;
home-primary-user = mkPrimaryUserModule "home";
@ -247,18 +234,21 @@
templates = import ./templates;
} // 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 {
src = ./.;
hooks = {
deadnix.enable = true;
nixpkgs-fmt.enable = true;
nil.enable = true;
nixfmt.enable = true;
statix.enable = true;
};
};
devShells = let pkgs = self.legacyPackages.${system}; in {
devShells = let pkgs = self.legacyPackages.${system};
in {
default = pkgs.mkShell {
inherit (self.checks.${system}.pre-commit) shellHook;
};

View File

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

View File

@ -7,10 +7,7 @@
# Add Fish plugins
home.packages = builtins.attrValues {
inherit (pkgs.fishPlugins)
autopair-fish
colored-man-pages
done;
inherit (pkgs.fishPlugins) autopair-fish colored-man-pages done;
};
programs.fish.plugins = [ pkgs.fishPlugins.fisher ];
@ -136,10 +133,8 @@
# Aliases
programs.fish.shellAliases =
let
inherit (config.home.primaryUser) nixConfigDirectory;
in
{
let inherit (config.home.primaryUser) nixConfigDirectory;
in {
# Nix related
from-nix = "from-dir ${nixConfigDirectory}";
# darwin-rebuild build
@ -147,7 +142,8 @@
# darwin-rebuild switch full
drsf = "from-nix darwin-rebuild switch --flake .";
# 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
drc = "code ${nixConfigDirectory}";
# edit darwin-rebuild config in vim
@ -164,7 +160,8 @@
nsh = "nix shell";
nshu = "nix-unfree shell";
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
".." = "cd ..";
@ -183,7 +180,8 @@
colortest = "${pkgs.terminal-colors}/bin/terminal-colors -o";
} // lib.optionalAttrs pkgs.stdenv.isDarwin {
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`.

View File

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

View File

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

View File

@ -1,41 +1,34 @@
{ pkgs, ... }:
# Let-In --------------------------------------------------------------------------------------- {{{
let
colorsToKitty = colors: with colors; {
inherit
background
foreground
selection_background
selection_foreground
tab_bar_background
active_tab_background
active_tab_foreground
inactive_tab_background
inactive_tab_foreground;
cursor = white;
cursor_text_color = background;
color0 = black;
color8 = black;
color1 = red;
color9 = red;
color2 = green;
color10 = lime;
color3 = yellow;
color11 = orange;
color4 = blue;
color12 = blue;
color5 = magenta;
color13 = magenta;
color6 = cyan;
color14 = cyan;
color7 = white;
color15 = white;
url_color = brightgreen;
};
colorsToKitty = colors:
with colors; {
inherit background foreground selection_background selection_foreground
tab_bar_background active_tab_background active_tab_foreground
inactive_tab_background inactive_tab_foreground;
cursor = white;
cursor_text_color = background;
color0 = black;
color8 = black;
color1 = red;
color9 = red;
color2 = green;
color10 = lime;
color3 = yellow;
color11 = orange;
color4 = blue;
color12 = blue;
color5 = magenta;
color13 = magenta;
color6 = cyan;
color14 = cyan;
color7 = white;
color15 = white;
url_color = brightgreen;
};
font = "Rec Mono Duotone";
in
# }}}
{
# }}}
in {
# Kitty terminal
# https://sw.kovidgoyal.net/kitty/conf.html
# 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
bat = {
enable = true;
config = {
style = "auto";
};
config = { style = "auto"; };
};
# Direnv, load and unload environment variables depending on the current directory.
# https://direnv.net
@ -16,12 +14,8 @@
enable = true;
nix-direnv.enable = true;
};
nix-index = {
enable = true;
};
nushell = {
enable = true;
};
nix-index = { enable = true; };
nushell = { enable = true; };
ssh = {
enable = true;
matchBlocks."*".extraOptions = lib.optionalAttrs pkgs.stdenv.isDarwin {
@ -31,11 +25,9 @@
};
# vscode = {
# enable = true;
# extensions = [ pijul-vscode ];
# extensions = [ pijul-vscode ];
# };
zoxide = {
enable = true;
};
zoxide = { enable = true; };
};
# }}}
@ -43,22 +35,17 @@
home.packages = builtins.attrValues ({
inherit (pkgs)
# GUI apps
cinny
discord-ptb
lagrange
obsidian
slack
zoom-us
# GUI apps
cinny discord-ptb lagrange obsidian slack zoom-us
# System
curl wget
# lightweight session management
abduco
# archive tool
atool
# fancy version of `top` with ASCII graphs
bottom
curl
# fancy version of `du`
du-dust
# fancy version of `ls`
@ -79,7 +66,6 @@
thefuck
# extract RAR archives
unrar
wget
# extract XZ archives
xz
@ -106,23 +92,19 @@
xh
# Useful nix related tools
nixfmt nix-prefetch-git nix-tree
# adding/managing alternative binary caches hosted by Cachix
cachix
# run software from nixpkgs without installing it
comma
nixpkgs-fmt
nix-prefetch-git
nix-tree
# nix language server
nil
;
nil;
} // lib.optionalAttrs pkgs.stdenv.isDarwin {
inherit (pkgs)
# useful macOS CLI commands
# useful macOS CLI commands
m-cli
# see /overlays/colors.nix
is-dark-mode
;
is-dark-mode;
});
# }}}
}

View File

@ -2,8 +2,8 @@
# dark-mode-notify configuration
# {{{
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;
config = {
Label = "ke.bou.dark-mode-notify";

View File

@ -1,48 +1,43 @@
{ config, pkgs, ... }: {
# tarsnap periodic backup configuration
# {{{
launchd.agents.tarsnap =
let
logPath = "${config.xdg.stateHome}/tarsnap";
tarsnapBackup = pkgs.writeShellScriptBin "tarsnap-backup-helper" ''
date=$(date -u +%Y-%m-%dT%H:%M:%SZ)
echo
echo "Running tarsnap backup for $date"
/opt/homebrew/bin/tarsnap -c \
--configfile ${config.home.homeDirectory}/.tarsnaprc \
--keyfile ${config.xdg.configHome}/tarsnap/write-only.key \
-f $(uname -n)-$date \
${config.home.homeDirectory}/{dotfiles.nix,Desktop,Development,Documents,Downloads}
'';
in
{
enable = true;
config = {
Label = "com.tarsnap.tarsnap";
StandardErrorPath = "${logPath}/error.log";
StandardOutPath = "${logPath}/out.log";
StartCalendarInterval = [
{
# every sunday
Weekday = 0;
# at midnight
Hour = 0;
Minute = 0;
}
{
# every wednesday
Weekday = 3;
# at noon
Hour = 12;
Minute = 0;
}
];
Program = "${tarsnapBackup}/bin/tarsnap-backup-helper";
};
launchd.agents.tarsnap = let
logPath = "${config.xdg.stateHome}/tarsnap";
tarsnapBackup = pkgs.writeShellScriptBin "tarsnap-backup-helper" ''
date=$(date -u +%Y-%m-%dT%H:%M:%SZ)
echo
echo "Running tarsnap backup for $date"
/opt/homebrew/bin/tarsnap -c \
--configfile ${config.home.homeDirectory}/.tarsnaprc \
--keyfile ${config.xdg.configHome}/tarsnap/write-only.key \
-f $(uname -n)-$date \
${config.home.homeDirectory}/{dotfiles.nix,Desktop,Development,Documents,Downloads}
'';
in {
enable = true;
config = {
Label = "com.tarsnap.tarsnap";
StandardErrorPath = "${logPath}/error.log";
StandardOutPath = "${logPath}/out.log";
StartCalendarInterval = [
{
# every sunday
Weekday = 0;
# at midnight
Hour = 0;
Minute = 0;
}
{
# every wednesday
Weekday = 3;
# at noon
Hour = 12;
Minute = 0;
}
];
Program = "${tarsnapBackup}/bin/tarsnap-backup-helper";
};
};
# }}}
}

View File

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

View File

@ -9,12 +9,14 @@
# See docs here: https://starship.rs/config/
# Symbols config configured in Flake.
battery.display = [
{ threshold = 25; } # display battery information if charge is <= 25%
];
battery.display = [{
threshold = 25;
} # display battery information if charge is <= 25%
];
directory.fish_style_pwd_dir_length = 1; # turn on fish directory truncation
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
self: inputs: nixpkgs:
{ primaryUser
, system ? "aarch64-darwin"
{ primaryUser, system ? "aarch64-darwin"
# `nix-darwin` modules to include
, modules ? [ ]
@ -12,20 +11,19 @@ self: inputs: nixpkgs:
# Value for `home-manager`'s `home.stateVersion` option.
, homeStateVersion
# `home-manager` modules to include
# `home-manager` modules to include
, homeModules ? [ ]
# Additional `home-manager` modules to include, useful when reusing a configuration with
# `lib.makeOverridable`.
, extraHomeModules ? [ ]
}:
, extraHomeModules ? [ ] }:
inputs.darwin.lib.darwinSystem {
inherit system;
modules = modules ++ extraModules ++ [
inputs.home-manager.darwinModules.home-manager
({ config, ... }:
let cfg = config.users.primaryUser; in
{
let cfg = config.users.primaryUser;
in {
users.primaryUser = primaryUser;
inherit nixpkgs;

View File

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

View File

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

View File

@ -7,10 +7,12 @@ let
cfg = config.programs.kitty.extras;
# 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
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
kitty-colors = pkgs.symlinkJoin {
@ -36,8 +38,7 @@ let
term-dark = pkgs.writeShellScriptBin "term-dark" ''
${term-background}/bin/term-background ${cfg.colors.dark-name}
'';
in
{
in {
options.programs.kitty.extras = {
colors = {
@ -112,13 +113,13 @@ in
appPath = mkOption {
type = types.str;
default = null;
description = ''Path to kitty.app'';
description = "Path to kitty.app";
};
iconPath = mkOption {
type = types.str;
default = null;
description = ''Path to kitty icns'';
description = "Path to kitty icns";
};
};
@ -126,41 +127,38 @@ in
config = mkIf config.programs.kitty.enable {
home.packages = mkIf cfg.colors.enable [
term-light
term-dark
term-background
];
home.packages =
mkIf cfg.colors.enable [ term-light term-dark term-background ];
home.activation =
let
fileicon = "/opt/homebrew/bin/fileicon";
in
mkIf (pkgs.stdenv.isDarwin && cfg.fixIcon.enable) {
cleanupKittyIcon = lib.hm.dag.entryBetween [ "darwinApps" ] [ "writeBoundary" ] ''
home.activation = let fileicon = "/opt/homebrew/bin/fileicon";
in mkIf (pkgs.stdenv.isDarwin && cfg.fixIcon.enable) {
cleanupKittyIcon =
lib.hm.dag.entryBetween [ "darwinApps" ] [ "writeBoundary" ] ''
if ${fileicon} test ${cfg.fixIcon.appPath};
then
$DRY_RUN_CMD sudo ${fileicon} rm ${cfg.fixIcon.appPath}
fi
'';
fixKittyIcon = lib.hm.dag.entryAfter [ "darwinApps" ] ''
$DRY_RUN_CMD sudo ${fileicon} set ${cfg.fixIcon.appPath} ${cfg.fixIcon.iconPath}
'';
};
fixKittyIcon = lib.hm.dag.entryAfter [ "darwinApps" ] ''
$DRY_RUN_CMD sudo ${fileicon} set ${cfg.fixIcon.appPath} ${cfg.fixIcon.iconPath}
'';
};
programs.kitty.settings = optionalAttrs cfg.colors.enable
{
allow_remote_control = "yes";
listen_on = "unix:/tmp/mykitty";
} // optionalAttrs (cfg.useSymbolsFromNerdFont != "") {
programs.kitty.settings = optionalAttrs cfg.colors.enable {
allow_remote_control = "yes";
listen_on = "unix:/tmp/mykitty";
} // optionalAttrs (cfg.useSymbolsFromNerdFont != "") {
# 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" =
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,21 +1,20 @@
optionName: { config, lib, pkgs, ... }:
optionName:
{ config, lib, pkgs, ... }:
let
inherit (lib) mkOption types;
inherit (pkgs.stdenv) isDarwin;
cfg = config.${optionName}.primaryUser;
in
{
in {
options.${optionName}.primaryUser = {
username = mkOption { type = types.str; };
fullName = mkOption { type = types.str; };
email = mkOption { type = types.str; };
homeDirectory = mkOption {
type = types.str;
default =
let prefix = if isDarwin then "/Users" else "/home";
in "${prefix}/${cfg.username}";
default = let prefix = if isDarwin then "/Users" else "/home";
in "${prefix}/${cfg.username}";
};
nixConfigDirectory = mkOption {
type = types.str;

View File

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

View File

@ -5,7 +5,8 @@ stdenv.mkDerivation {
pname = "cinny";
nativeBuildInputs = [ undmg unzip ];
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=";
};

View File

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

View File

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

View File

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

View File

@ -5,7 +5,8 @@ stdenv.mkDerivation {
pname = "yubiswitch";
nativeBuildInputs = [ undmg unzip ];
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=";
};

View File

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

View File

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