More reorganizing

work
mat ess 2022-12-21 00:22:57 -05:00
parent 813efc75be
commit 8bf3fdae1c
8 changed files with 307 additions and 261 deletions

View File

@ -23,22 +23,24 @@
trusted-users = [ trusted-users = [
"@admin" "@admin"
]; ];
# TODO: remove and replace with a launchd job
# 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;
# Auto upgrade nix package and the daemon service. # Auto upgrade nix package and the daemon service.
services.nix-daemon.enable = true; services.nix-daemon.enable = true;
# Make Fish the default shell # Make Fish the default shell
environment.shells = with pkgs; [ environment.shells = lib.mkForce (builtins.attrValues {
bashInteractive inherit (pkgs)
fish bashInteractive
zsh fish
]; zsh;
});
programs.fish.enable = true; programs.fish.enable = true;
programs.fish.useBabelfish = true; programs.fish.useBabelfish = true;

View File

@ -1,4 +1,9 @@
{ config, pkgs, ... }: { { config, pkgs, lib, ... }:
let
inherit (config.users) primaryUser;
caskPresent = cask: lib.any (x: x.name == cask) config.homebrew.casks;
in
{
environment.shellInit = '' environment.shellInit = ''
eval "$(${config.homebrew.brewPrefix}/brew shellenv)" eval "$(${config.homebrew.brewPrefix}/brew shellenv)"
''; '';
@ -73,6 +78,20 @@
# "zoom" # "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_SOCKET = socket;
programs.ssh = {
enable = true;
matchBlocks."*".extraOptions = {
IdentityAgent = socket;
};
};
};
# For cli packages that aren't currently available for macOS in `nixpkgs`.Packages should be # For cli packages that aren't currently available for macOS in `nixpkgs`.Packages should be
# installed in `../home/programs.nix` whenever possible. # installed in `../home/programs.nix` whenever possible.
homebrew.brews = [ homebrew.brews = [

View File

@ -39,11 +39,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1668784520, "lastModified": 1671196037,
"narHash": "sha256-gGgVAMwYPPmrfnvnoRi6OkEB5KRsNTb9uYzEceLdO/g=", "narHash": "sha256-2+J98SeczFWonbqFLMEAQC7vZEe6I2gM17XYvEmG52I=",
"owner": "lnl7", "owner": "lnl7",
"repo": "nix-darwin", "repo": "nix-darwin",
"rev": "6349b99bc2b96ded34d068a88c7c5ced406b7f7f", "rev": "adb8ac0453c8b2c40f5bffb578453dbaee838952",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -244,11 +244,11 @@
"rust-overlay": "rust-overlay" "rust-overlay": "rust-overlay"
}, },
"locked": { "locked": {
"lastModified": 1671493763, "lastModified": 1671579194,
"narHash": "sha256-xw8cemaLh9Nda9usE0z3sxeiDUuXZ1zDiO6md3i7XLg=", "narHash": "sha256-Cpm5tjSfBWOyAUvKcTRk6++U6n2ADkvro7jvfFJe3ps=",
"owner": "helix-editor", "owner": "helix-editor",
"repo": "helix", "repo": "helix",
"rev": "bdeefbfb23077fcbbfe1e7df6c6ac88516244bbc", "rev": "6ab8591715daf932d0dc45d0d5fb9e5a272f2fe1",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -267,11 +267,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1670513770, "lastModified": 1671578428,
"narHash": "sha256-muL74fsbGA8K8WlZSPNWddOiuBnC54kAajncX6nXrh4=", "narHash": "sha256-YmbpBcPaGz9KE2bC4xPvSdgCSMk0BmS/L3ePvy9TR/M=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "054d9e3187ca00479e8036dc0e92900a384f30fd", "rev": "0f8bf4f92efa3c6168705b49a6788abb3612033a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -372,11 +372,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1671268780, "lastModified": 1671458120,
"narHash": "sha256-9Okbivo10bcXEGCtmAQNfJt1Zpk6B3tjkSQ2CIXmTCg=", "narHash": "sha256-2+k/OONN4OF21TeoNjKB5sXVZv6Zvm/uEyQIW9OYCg8=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "80c24eeb9ff46aa99617844d0c4168659e35175f", "rev": "e37ef84b478fa8da0ced96522adfd956fde9047a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -406,11 +406,11 @@
}, },
"nixpkgs-master": { "nixpkgs-master": {
"locked": { "locked": {
"lastModified": 1670797596, "lastModified": 1671578743,
"narHash": "sha256-lc4b690J8iiYnNToc5j39N6gt3k9lQUDxe0D6Wzuj9k=", "narHash": "sha256-kNtZiBrKuaepKEtix+6mM6JJxF6iU+MAdqc/fmZS1aU=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "fb83ee7d26bee200b2bd6b69df390c57dee4b6af", "rev": "5b727aeb18b7896e852866be0abb9a9f5b10c9a3",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -422,48 +422,16 @@
}, },
"nixpkgs-stable": { "nixpkgs-stable": {
"locked": { "locked": {
"lastModified": 1659446231, "lastModified": 1671391912,
"narHash": "sha256-hekabNdTdgR/iLsgce5TGWmfIDZ86qjPhxDg/8TlzhE=", "narHash": "sha256-W8sbJuN/i+OZdRuIzDiIyKOqVB/G26zh9DQL1rfp2xk=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "eabc38219184cc3e04a974fe31857d8e0eac098d", "rev": "09e8ac77744dd036e58ab2284e6f5c03a6d6ed41",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "owner": "NixOS",
"ref": "nixpkgs-21.11-darwin", "ref": "nixpkgs-22.11-darwin",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-stable_2": {
"locked": {
"lastModified": 1668984258,
"narHash": "sha256-0gDMJ2T3qf58xgcSbYoXiRGUkPWmKyr5C3vcathWhKs=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "cf63ade6f74bbc9d2a017290f1b2e33e8fbfa70a",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-22.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1668994630,
"narHash": "sha256-1lqx6HLyw6fMNX/hXrrETG1vMvZRGm2XVC9O/Jt0T6c=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "af50806f7c6ab40df3e6b239099e8f8385f6c78b",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
@ -475,15 +443,19 @@
"flake-utils" "flake-utils"
], ],
"gitignore": "gitignore", "gitignore": "gitignore",
"nixpkgs": "nixpkgs_2", "nixpkgs": [
"nixpkgs-stable": "nixpkgs-stable_2" "nixpkgs"
],
"nixpkgs-stable": [
"nixpkgs-stable"
]
}, },
"locked": { "locked": {
"lastModified": 1670413394, "lastModified": 1671452357,
"narHash": "sha256-M7sWqrKtOqUv9euX1t3HCxis8cPy9MNiZxQmUf0KF1o=", "narHash": "sha256-HqzXiQEegpRQ4VEl9pEPgHSIxhJrNJ27HfN1wOc7w2E=",
"owner": "cachix", "owner": "cachix",
"repo": "pre-commit-hooks.nix", "repo": "pre-commit-hooks.nix",
"rev": "1303a1a76e9eb074075bfe566518c413f6fc104e", "rev": "200790e9c77064c53eaf95805b013d96615ecc27",
"type": "github" "type": "github"
}, },
"original": { "original": {

227
flake.nix
View File

@ -4,7 +4,7 @@
inputs = { inputs = {
# Package sets # Package sets
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nixpkgs-stable.url = "github:NixOS/nixpkgs/nixpkgs-21.11-darwin"; nixpkgs-stable.url = "github:NixOS/nixpkgs/nixpkgs-22.11-darwin";
nixpkgs-master.url = "github:NixOS/nixpkgs/master"; nixpkgs-master.url = "github:NixOS/nixpkgs/master";
# Flake helpers # Flake helpers
@ -22,6 +22,8 @@
# pre-commit and hooks # pre-commit and hooks
pre-commit.url = "github:cachix/pre-commit-hooks.nix"; pre-commit.url = "github:cachix/pre-commit-hooks.nix";
pre-commit.inputs.nixpkgs.follows = "nixpkgs";
pre-commit.inputs.nixpkgs-stable.follows = "nixpkgs-stable";
pre-commit.inputs.flake-utils.follows = "flake-utils"; pre-commit.inputs.flake-utils.follows = "flake-utils";
# Extra sources # Extra sources
@ -41,7 +43,6 @@
outputs = outputs =
{ self { self
, home-manager
, flake-utils , flake-utils
, pre-commit , pre-commit
, ... , ...
@ -61,12 +62,10 @@
# Configuration for `nixpkgs` # Configuration for `nixpkgs`
nixpkgsConfig = { nixpkgsConfig = {
config = { allowUnfree = true; }; config = { allowUnfree = true; };
overlays = attrValues self.overlays ++ [ overlays = attrValues self.overlays;
(import ./pkgs { inherit inputs; })
];
}; };
homeManagerStateVersion = "22.05"; homeStateVersion = "22.05";
primaryUserInfo = { primaryUserInfo = {
username = "mat"; username = "mat";
@ -80,115 +79,96 @@
email = "mess@yelp.com"; email = "mess@yelp.com";
}; };
# Modules shared by most `nix-darwin` personal configurations. # helper for defining nix-darwin systems
nixDarwinCommonModules = attrValues self.darwinModules ++ [ mkDarwinSystem =
# `home-manager` module { modules ? [ ]
home-manager.darwinModules.home-manager , homeModules ? [ ]
( , ...
{ config, ... }: }@args: import ./lib/mkDarwinSystem.nix self inputs nixpkgsConfig (args // {
let inherit homeStateVersion;
inherit (config.users) primaryUser; modules = attrValues self.darwinModules ++ modules;
in homeModules = attrValues self.homeManagerModules ++ homeModules;
{ });
nixpkgs = nixpkgsConfig;
# Hack to support legacy worklows that use `<nixpkgs>`, darwin-option, etc.
nix.nixPath = {
nixpkgs = "${inputs.nixpkgs}";
darwin = "${inputs.darwin}";
};
# `home-manager` config
users.users.${primaryUser.username}.home = primaryUser.homeDirectory;
home-manager.useGlobalPkgs = true;
home-manager.users.${primaryUser.username} = {
imports = attrValues self.homeManagerModules;
home.stateVersion = homeManagerStateVersion;
home.primaryUser = primaryUser;
home.homeDirectory = primaryUser.homeDirectory;
home.enableNixpkgsReleaseCheck = true;
};
# Add a registry entry for this flake
nix.registry.my.flake = self;
}
)
];
in in
{ {
# `nix-darwin` configs # `nix-darwin` configs
darwinConfigurations = rec { darwinConfigurations =
# Mininal configurations to bootstrap systems 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
{
# Mininal configurations to bootstrap systems
inherit bootstrap-x86;
bootstrap-arm = bootstrap-x86.override { system = "aarch64-darwin"; };
# M1 MBP
matbook = mkDarwinSystem {
primaryUser = primaryUserInfo;
modules = [
({ pkgs, ... }: {
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;
}];
})
];
};
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 = "csdev4";
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;
}];
})
];
};
}; };
bootstrap-arm = bootstrap-x86.override { system = "aarch64-darwin"; };
# M1 MBP
matbook = darwinSystem {
system = "aarch64-darwin";
modules = nixDarwinCommonModules ++ [
({ pkgs, ... }: {
users.primaryUser = primaryUserInfo;
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;
}];
})
];
};
yelpbook-m1 = darwinSystem {
system = "aarch64-darwin";
modules = nixDarwinCommonModules ++ [
({ 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 = builtins.attrValues { inherit (pkgs) yubiswitch; };
programs.ssh.matchBlocks.devbox = {
hostname = "csdev4";
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 --------------------------------------------------------------- {{{ # Overlays --------------------------------------------------------------- {{{
@ -229,6 +209,8 @@
homebrew-enabled = _: prev: optionalAttrs prev.stdenv.isDarwin { homebrew-enabled = _: prev: optionalAttrs prev.stdenv.isDarwin {
lib = prev.lib // { homebrew-enabled = inputs.homebrew-enabled.value; }; lib = prev.lib // { homebrew-enabled = inputs.homebrew-enabled.value; };
}; };
extra-pkgs = import ./pkgs { inherit inputs; };
}; };
# `nix-darwin` configs and modules # `nix-darwin` configs and modules
@ -263,24 +245,9 @@
home-primary-user = mkPrimaryUserModule "home"; home-primary-user = mkPrimaryUserModule "home";
}; };
templates = { templates = import ./templates;
rust = { } // flake-utils.lib.eachDefaultSystem (system: {
description = "A rust flake template based on flake.parts"; legacyPackages = import inputs.nixpkgs (nixpkgsConfig // { inherit system; });
welcomeText = ''
welcome to a new rust project ()
run `direnv allow` and `cargo init` to start a new project
'';
path = ./templates/rust;
};
};
} // flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import inputs.nixpkgs (nixpkgsConfig // { inherit system; });
in
{
legacyPackages = pkgs;
checks.pre-commit = pre-commit.lib.${system}.run { checks.pre-commit = pre-commit.lib.${system}.run {
src = ./.; src = ./.;
@ -292,7 +259,7 @@
}; };
}; };
devShells = { 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

@ -138,7 +138,6 @@
programs.fish.shellAliases = programs.fish.shellAliases =
let let
inherit (config.home.primaryUser) nixConfigDirectory; inherit (config.home.primaryUser) nixConfigDirectory;
inherit (pkgs) bat bottom du-dust exa gitAndTools stdenv xh;
in in
{ {
# Nix related # Nix related
@ -170,18 +169,18 @@
# Other # Other
".." = "cd .."; ".." = "cd ..";
":q" = "exit"; ":q" = "exit";
cat = "${bat}/bin/bat --style=plain --paging=never"; cat = "${pkgs.bat}/bin/bat --style=plain --paging=never";
du = "${du-dust}/bin/dust"; du = "${pkgs.du-dust}/bin/dust";
g = "${gitAndTools.git}/bin/git"; g = "${pkgs.gitAndTools.git}/bin/git";
ls = "${exa}/bin/exa"; ls = "${pkgs.exa}/bin/exa";
ll = "ls -l --time-style long-iso --icons"; ll = "ls -l --time-style long-iso --icons";
la = "ll -a"; la = "ll -a";
http = "${xh}/bin/xh"; http = "${pkgs.xh}/bin/xh";
https = "${xh}/bin/xhs"; https = "${pkgs.xh}/bin/xhs";
top = "${bottom}/bin/btm"; top = "${pkgs.bottom}/bin/btm";
htop = "${bottom}/bin/btm"; htop = "${pkgs.bottom}/bin/btm";
tb = "toggle-background"; tb = "toggle-background";
} // lib.optionalAttrs 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";
}; };
@ -193,7 +192,7 @@
''; '';
programs.fish.interactiveShellInit = '' programs.fish.interactiveShellInit = ''
set -g fish_greeting (set_color blue)"( ³) "(set_color red)"h"(set_color cyan)"e"(set_color yellow)"l"(set_color magenta)"l"(set_color green)"o "(set_color blue)"( ³)"(set_color normal) set -g fish_greeting (set_color blue)"( ³) "(set_color cyan)"h"(set_color red)"e"(set_color yellow)"l"(set_color green)"l"(set_color magenta)"o "(set_color blue)"( ³)"(set_color normal)
fish_vi_key_bindings fish_vi_key_bindings
set VIRTUAL_ENV_DISABLE_PROMPT true set VIRTUAL_ENV_DISABLE_PROMPT true
bind -M insert ! __history_previous_command bind -M insert ! __history_previous_command

View File

@ -1,13 +1,5 @@
{ config, pkgs, lib, ... }: { pkgs, lib, ... }: {
let
secretiveAuthSocket = "${config.home.homeDirectory}/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh";
in
{
# Programs + packages with configuration --------------------------------------------------------------- {{{ # Programs + packages with configuration --------------------------------------------------------------- {{{
home.sessionVariables = lib.optionalAttrs pkgs.stdenv.isDarwin {
SSH_AUTH_SOCK = secretiveAuthSocket;
};
programs = { programs = {
# a nicer cat # a nicer cat
# https://rycee.gitlab.io/home-manager/options.html#opt-programs.bat.enable # https://rycee.gitlab.io/home-manager/options.html#opt-programs.bat.enable
@ -33,7 +25,6 @@ in
matchBlocks."*".extraOptions = lib.optionalAttrs pkgs.stdenv.isDarwin { matchBlocks."*".extraOptions = lib.optionalAttrs pkgs.stdenv.isDarwin {
UseKeychain = "yes"; UseKeychain = "yes";
AddKeysToAgent = "yes"; AddKeysToAgent = "yes";
IdentityAgent = secretiveAuthSocket;
}; };
}; };
# vscode # vscode
@ -50,55 +41,84 @@ in
# Other packages ----------------------------------------------------------------------------- {{{ # Other packages ----------------------------------------------------------------------------- {{{
home.packages = with pkgs; [ home.packages = builtins.attrValues ({
# GUI apps coreutils = pkgs.coreutils.override { withPrefix = true; singleBinary = "shebangs"; };
discord-ptb inherit (pkgs)
element-desktop # GUI apps
lagrange discord-ptb
obsidian element-desktop
slack lagrange
zoom-us obsidian
slack
zoom-us
# System # System
abduco # lightweight session management # lightweight session management
atool # archive tool abduco
bottom # fancy version of `top` with ASCII graphs # archive tool
# do i need these? atool
# coreutils # fancy version of `top` with ASCII graphs
curl bottom
du-dust # fancy version of `du` curl
exa # fancy version of `ls` # fancy version of `du`
fd # fancy version of `find` du-dust
mosh # wrapper for `ssh` that better at not dropping connections # fancy version of `ls`
procs # fancy version of `ps` exa
pv # pipe progress viewer # fancy version of `find`
rage # command line file encryption fd
thefuck # wrapper for `ssh` that better at not dropping connections
unrar # extract RAR archives mosh
wget # fancy version of `ps`
xz # extract XZ archives procs
# pipe progress viewer
pv
# command line file encryption
rage
thefuck
# extract RAR archives
unrar
wget
# extract XZ archives
xz
# Dev stuff # Dev stuff
cloc # source code line counter # source code line counter
doctl # command line tools for digitalocean cloc
flyctl # command line tools for fly.io # command line tools for digitalocean
hyperfine # benchmarking tool doctl
jq # json processor # command line tools for fly.io
pijul # alternative to `git` flyctl
ripgrep # better version of `grep` # benchmarking tool
tealdeer # rust implementation of `tldr` hyperfine
xh # reimplementation of `httpie` in rust # json processor
jq
# alternative to `git`
pijul
# better version of `grep`
ripgrep
# rust implementation of `tldr`
tealdeer
# reimplementation of `httpie` in rust
xh
# Useful nix related tools # Useful nix related tools
cachix # adding/managing alternative binary caches hosted by Cachix # adding/managing alternative binary caches hosted by Cachix
comma # run software from nixpkgs without installing it cachix
nixpkgs-fmt # run software from nixpkgs without installing it
nix-prefetch-git comma
nix-tree nixpkgs-fmt
nil # nix language server nix-prefetch-git
] ++ lib.optionals stdenv.isDarwin [ nix-tree
m-cli # useful macOS CLI commands # nix language server
is-dark-mode # see /overlays/colors.nix nil
]; ;
} // lib.optionalAttrs pkgs.stdenv.isDarwin {
inherit (pkgs)
# useful macOS CLI commands
m-cli
# see /overlays/colors.nix
is-dark-mode
;
});
# }}} # }}}
} }

56
lib/mkDarwinSystem.nix Normal file
View File

@ -0,0 +1,56 @@
# taken from https://github.com/malob/nixpkgs/blob/27e04346555277687a60c0168969b3945c2b25ba/lib/mkDarwinSystem.nix
self: inputs: nixpkgs:
{ primaryUser
, system ? "aarch64-darwin"
# `nix-darwin` modules to include
, modules ? [ ]
# Additional `nix-darwin` modules to include, useful when reusing a configuration with
# `lib.makeOverridable`.
, extraModules ? [ ]
# Value for `home-manager`'s `home.stateVersion` option.
, homeStateVersion
# `home-manager` modules to include
, homeModules ? [ ]
# Additional `home-manager` modules to include, useful when reusing a configuration with
# `lib.makeOverridable`.
, extraHomeModules ? [ ]
}:
inputs.darwin.lib.darwinSystem {
inherit system;
modules = modules ++ extraModules ++ [
inputs.home-manager.darwinModules.home-manager
({ config, ... }:
let cfg = config.users.primaryUser; in
{
users.primaryUser = primaryUser;
inherit nixpkgs;
# Support legacy workflows that use `<nixpkgs>` etc.
nix.nixPath = {
nixpkgs = "${inputs.nixpkgs}";
darwin = "${inputs.darwin}";
};
# `home-manager` config
users.users.${cfg.username}.home = cfg.homeDirectory;
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.${cfg.username} = {
imports = homeModules ++ extraHomeModules;
home.stateVersion = homeStateVersion;
home.primaryUser = primaryUser;
home.homeDirectory = cfg.homeDirectory;
home.enableNixpkgsReleaseCheck = true;
};
# Make sure nixpkgs#pkg refers to this nixpkgs
nix.registry.nixpkgs.flake = inputs.nixpkgs;
# Add this flake to the registry
nix.registry.my.flake = self;
})
];
}

11
templates/default.nix Normal file
View File

@ -0,0 +1,11 @@
{
rust = {
description = "A rust flake template based on flake.parts";
welcomeText = ''
welcome to a new rust project ()
run `direnv allow` and `cargo init` to start a new project
'';
path = ./templates/rust;
};
}