Compare commits

...

2 commits

Author SHA1 Message Date
96e14ada20
Consolidate definitions
This pulls in several additional flakes to assist with per-system outputs, and largely improves readability.
2024-04-11 00:14:53 -05:00
1025996f60
Add ripgrep 2024-04-10 22:28:38 -05:00
3 changed files with 125 additions and 56 deletions

60
flake.lock generated
View file

@ -1,5 +1,35 @@
{
"nodes": {
"all-systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"darwin-systems": {
"locked": {
"lastModified": 1689347925,
"narHash": "sha256-ozenz5bFe1UUqOn7f60HRmgc01BgTGIKZ4Xl+HbocGQ=",
"owner": "nix-systems",
"repo": "default-darwin",
"rev": "2235d7e6cc29ae99878133c95e9fe5e157661ffb",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default-darwin",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
@ -7,11 +37,11 @@
]
},
"locked": {
"lastModified": 1712212014,
"narHash": "sha256-s+lbaf3nLRn1++/X2eXwY9mYCA/m9l8AvyG8beeOaXE=",
"lastModified": 1712759992,
"narHash": "sha256-2APpO3ZW4idlgtlb8hB04u/rmIcKA8O7pYqxF66xbNY=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "7e91f2a0ba4b62b88591279d54f741a13e36245b",
"rev": "31357486b0ef6f4e161e002b6893eeb4fafc3ca9",
"type": "github"
},
"original": {
@ -20,13 +50,28 @@
"type": "github"
}
},
"linux-systems": {
"locked": {
"lastModified": 1689347949,
"narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
"owner": "nix-systems",
"repo": "default-linux",
"rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default-linux",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1712163089,
"narHash": "sha256-Um+8kTIrC19vD4/lUCN9/cU9kcOsD1O1m+axJqQPyMM=",
"lastModified": 1712608508,
"narHash": "sha256-vMZ5603yU0wxgyQeHJryOI+O61yrX2AHwY6LOFyV1gM=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "fd281bd6b7d3e32ddfa399853946f782553163b5",
"rev": "4cba8b53da471aea2ab2b0c1f30a81e7c451f4b6",
"type": "github"
},
"original": {
@ -38,7 +83,10 @@
},
"root": {
"inputs": {
"all-systems": "all-systems",
"darwin-systems": "darwin-systems",
"home-manager": "home-manager",
"linux-systems": "linux-systems",
"nixpkgs": "nixpkgs"
}
}

120
flake.nix
View file

@ -4,14 +4,26 @@
inputs = {
# Specify the source of Home Manager and Nixpkgs.
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
# Allows for easy enumeration of available Darwin and Linux systems.
all-systems.url = "github:nix-systems/default";
darwin-systems.url = "github:nix-systems/default-darwin";
linux-systems.url = "github:nix-systems/default-linux";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { nixpkgs, home-manager, ... }:
outputs = { nixpkgs, home-manager, linux-systems, darwin-systems, all-systems, ... }:
let
# TODO(spotlightishere): Is there a better way to approach this that doesn't
# involve importing so many separate flakes?
#
# (We could manually merge Darwin and Linux themselves, but this is primarily for readability.)
allSystems = nixpkgs.lib.genAttrs (import all-systems);
darwinSystems = nixpkgs.lib.genAttrs (import darwin-systems);
linuxSystems = nixpkgs.lib.genAttrs (import linux-systems);
homeManager = { system, specialArgs ? { } }:
home-manager.lib.homeManagerConfiguration {
modules = [
@ -22,64 +34,72 @@
};
in
{
packages = {
# We currently assume that all x86_64-linux devices only
# require dotfiles. For now, this is mostly true :)
x86_64-linux.homeConfigurations.spotlight = homeManager {
system = "x86_64-linux";
};
# There's a few things going on here that are all merged in the end.
# We start with system-specific packages, providing home-manager.
packages =
##########################
# Linux-specific options #
##########################
linuxSystems
(system: {
homeConfigurations = {
# First, we currently assume that Linux devices
# only require dotfiles and utilize the username `spotlight`.
#
# For now, this is effectively true, sans a few specific configurations :)
spotlight = homeManager {
system = system;
specialArgs = {
desktop = false;
gpg = false;
};
};
# Similarly (as of writing), all aarch64 Linux devices are headless
# and primarily managed by other distro package managers.
# This should likely be dealt with in the future!
aarch64-linux.homeConfigurations.spotlight = homeManager {
system = "aarch64-linux";
};
# For a special case: with the Steam Deck, we have to assume the user
# is named `deck` due to its immutable system image.
deck = homeManager {
system = system;
specialArgs = {
gpg = true;
username = "deck";
};
};
};
})
# For all architecture variants of Darwin, we don't want only dotfiles.
aarch64-darwin.homeConfigurations.spot = homeManager {
system = "aarch64-darwin";
specialArgs = {
desktop = true;
gpg = true;
//
###########################
# Darwin-specific options #
###########################
darwinSystems (system: {
# We use the username `spot` under Darwin.
# We also assume that desktop applications should be made available, alongside GPG.
homeConfigurations.spot = homeManager {
system = system;
specialArgs = {
desktop = true;
gpg = true;
};
};
};
x86_64-darwin.homeConfigurations.spot = homeManager {
system = "x86_64-darwin";
specialArgs = {
desktop = true;
gpg = true;
};
};
# For a special case: with the Steam Deck, we have to assume the user
# is named `deck` due to its immutable system image.
x86_64-linux.homeConfigurations.deck = homeManager {
system = "x86_64-linux";
specialArgs = {
gpg = true;
username = "deck";
};
};
};
});
# We provide a NixOS module for easy usage within other system flakes.
# (Again, we assume a default name of `spotlight` under Linux.)
nixosModules.default = {
imports = [
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.spotlight = import ./home/home.nix;
home-manager.extraSpecialArgs = { desktop = false; gpg = false; };
home-manager.nixosModules.home-manager {
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.spotlight = import ./home/home.nix;
extraSpecialArgs = { desktop = false; gpg = false; };
};
}
];
};
formatter = {
aarch64-darwin = nixpkgs.legacyPackages.aarch64-darwin.nixpkgs-fmt;
x86_64-darwin = nixpkgs.legacyPackages.x86_64-darwin.nixpkgs-fmt;
aarch64-linux = nixpkgs.legacyPackages.aarch64-linux.nixpkgs-fmt;
x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixpkgs-fmt;
};
# Lastly, ensure a formatter is available for all systems.
formatter = allSystems (system: nixpkgs.legacyPackages.${system}.nixpkgs-fmt);
};
}

View file

@ -41,6 +41,7 @@
pwgen
qemu
radare2
ripgrep
rustup
socat
swiftformat