dotfiles/flake.nix
2024-12-30 09:41:46 +01:00

118 lines
3 KiB
Nix

{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
nixvim = {
url = "github:nix-community/nixvim";
inputs.nixpkgs.follows = "nixpkgs";
};
t.url = "github:jdonszelmann/t-rs";
dumpasm.url = "github:jdonszelmann/dumpasm";
kitty-search = {
url = "github:trygveaa/kitty-kitten-search";
flake = false;
};
jujutsu = {
url = "github:martinvonz/jj";
inputs.nixpkgs.follows = "nixpkgs";
};
ghostty = {
url = "github:ghostty-org/ghostty";
inputs.nixpkgs-stable.follows = "nixpkgs";
inputs.nixpkgs-unstable.follows = "nixpkgs";
};
};
outputs =
{
home-manager,
nixpkgs,
flake-utils,
nixvim,
t,
dumpasm,
jujutsu,
ghostty,
...
}@inputs:
let
homeManagerModules = [ nixvim.homeManagerModules.nixvim ];
pkgsForSystem =
system:
import nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = [
(_: _: {
custom = {
t = t.packages.${system}.default;
inherit (dumpasm.packages.${system}) dumpasm;
inherit (jujutsu.packages.${system}) jujutsu;
inherit (ghostty.packages.${system}) ghostty;
};
})
];
};
mkHomeConfiguration =
root: args:
home-manager.lib.homeManagerConfiguration (
{
modules = [ root ] ++ homeManagerModules ++ (args.modules or [ ]);
pkgs = pkgsForSystem (args.system or "x86_64-linux");
}
// {
inherit (args) extraSpecialArgs;
}
);
in
flake-utils.lib.eachDefaultSystem (system: rec {
formatter = legacyPackages.nixfmt-classic;
legacyPackages = pkgsForSystem system;
pkgs = legacyPackages;
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
(pkgs.writeShellScriptBin "fast-repl" ''
source /etc/set-environment
nix repl --file "${./.}/repl.nix" $@
'')
(pkgs.writeShellScriptBin "apply-home" ''
nix run .#home-manager -- switch --flake .#$@
'')
(pkgs.writeShellScriptBin "apply" ''
apply-home $(hostname -f)
'')
];
};
})
// {
homeConfigurations = {
kili = mkHomeConfiguration (import ./hosts/kili/home.nix) {
extraSpecialArgs = { inherit inputs; };
};
ori = mkHomeConfiguration (import ./hosts/ori/home.nix) {
extraSpecialArgs = { inherit inputs; };
};
icecube = mkHomeConfiguration (import ./hosts/icecube/home.nix) {
extraSpecialArgs = { inherit inputs; };
};
};
inherit home-manager;
inherit (home-manager) packages;
};
}