2022-06-14 01:53:34 +01:00
|
|
|
{
|
|
|
|
description = "Samw's home environment, as managed by nix/home-manager.";
|
|
|
|
inputs = {
|
|
|
|
# Nixpkgs
|
2024-03-30 21:25:55 +00:00
|
|
|
nixpkgs = {url = "github:nixos/nixpkgs/release-23.11";};
|
|
|
|
nixpkgs-unstable = {url = "github:nixos/nixpkgs";};
|
2022-06-14 01:53:34 +01:00
|
|
|
# Other modules
|
|
|
|
home-manager = {
|
2024-03-30 21:25:55 +00:00
|
|
|
url = "github:nix-community/home-manager/release-23.11";
|
2022-06-14 01:53:34 +01:00
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
devshell = {
|
|
|
|
url = "github:numtide/devshell";
|
|
|
|
inputs.flake-utils.follows = "flake-utils";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
outputs = inputs: let
|
|
|
|
overlays = [
|
|
|
|
# Add our own local packages
|
|
|
|
(final: prev: rec {
|
|
|
|
# Make my local packages available as pkgs.mypkgs.<foo>
|
|
|
|
mypkgs = prev.callPackage ./pkgs {};
|
|
|
|
})
|
|
|
|
];
|
|
|
|
in (rec {
|
2022-09-26 15:12:26 +01:00
|
|
|
profiles = import ./home/profiles.nix;
|
2022-06-14 01:53:34 +01:00
|
|
|
lib = {
|
|
|
|
mkHome = {
|
2022-09-14 18:29:00 +01:00
|
|
|
profiles,
|
2022-06-14 01:53:34 +01:00
|
|
|
system,
|
|
|
|
username ? "samw",
|
|
|
|
}:
|
2022-09-14 18:29:00 +01:00
|
|
|
inputs.home-manager.lib.homeManagerConfiguration {
|
2023-01-07 13:47:13 +00:00
|
|
|
pkgs = (import inputs.nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
config.allowUnfree = true; # Yes I know it's bad for me
|
|
|
|
});
|
2022-12-15 17:31:22 +00:00
|
|
|
modules = [
|
|
|
|
{ home = {
|
|
|
|
inherit username;
|
|
|
|
homeDirectory =
|
|
|
|
if (inputs.nixpkgs.lib.systems.elaborate system).isDarwin
|
|
|
|
then "/Users/${username}"
|
|
|
|
else "/home/${username}";
|
|
|
|
stateVersion = "21.11";
|
2023-01-07 13:47:13 +00:00
|
|
|
};}] ++ profiles ++ [
|
|
|
|
{nixpkgs.overlays = overlays;}
|
|
|
|
# See comment in home/default.nix.
|
|
|
|
({ pkgs, ... }: {
|
|
|
|
nix = {
|
|
|
|
enable = true;
|
|
|
|
package = pkgs.nix;
|
|
|
|
settings.experimental-features = "nix-command flakes";
|
|
|
|
settings.max-jobs = "auto"; # Gotta go fast (build derivations in parallel)
|
2023-02-28 22:02:05 +00:00
|
|
|
# Pin the nixpkgs registry to our locked nixpkgs. This means that we
|
|
|
|
# get the same packages via e.g. nix shell as we have at the system
|
|
|
|
# level, so less duplication overall and no more fetching that 30MB src
|
|
|
|
# every time you run nix shell.
|
|
|
|
registry.nixpkgs.flake = inputs.nixpkgs;
|
2023-01-07 13:47:13 +00:00
|
|
|
};
|
|
|
|
})
|
|
|
|
];
|
2022-09-26 15:12:26 +01:00
|
|
|
extraSpecialArgs = {inherit system;};
|
2022-06-14 01:53:34 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
# Standalone home-manager configurations
|
2022-09-26 15:12:26 +01:00
|
|
|
homeConfigurations = {
|
2022-06-14 01:53:34 +01:00
|
|
|
boron = lib.mkHome {
|
|
|
|
system = "aarch64-darwin";
|
2022-09-26 15:21:44 +01:00
|
|
|
profiles = with profiles; [default dev dev-gui sensitive mac docker aws];
|
2022-06-14 01:53:34 +01:00
|
|
|
username = "samuel.willcocks";
|
|
|
|
};
|
|
|
|
zinc = lib.mkHome {
|
|
|
|
system = "aarch64-darwin";
|
2022-09-26 15:21:44 +01:00
|
|
|
profiles = with profiles; [default dev dev-gui sensitive mac];
|
2022-06-14 01:53:34 +01:00
|
|
|
};
|
2022-12-16 19:37:01 +00:00
|
|
|
luroy = lib.mkHome {
|
|
|
|
system = "x86_64-linux";
|
|
|
|
profiles = with profiles; [default dev];
|
|
|
|
};
|
2022-06-14 01:53:34 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
# Per-system things
|
|
|
|
// (inputs.flake-utils.lib.eachDefaultSystem (system: let
|
|
|
|
pkgs = import inputs.nixpkgs {
|
|
|
|
inherit system;
|
2023-06-16 12:41:27 +01:00
|
|
|
overlays = overlays ++ [inputs.devshell.overlays.default];
|
2022-06-14 01:53:34 +01:00
|
|
|
};
|
|
|
|
platform = pkgs.lib.systems.elaborate system;
|
|
|
|
in {
|
|
|
|
# Flake interface to my local packages.
|
|
|
|
# - `callPackage` puts some junk in mypkgs (`override` and
|
|
|
|
# `overrideDerivation`) so we filter out anything that isn't a derivation
|
|
|
|
# - We also filter out any packages that aren't supported on the current
|
|
|
|
# platform.
|
2022-06-14 02:00:46 +01:00
|
|
|
packages = with pkgs.lib; (filterAttrs (_: v: (isDerivation v && meta.availableOn platform v)) pkgs.mypkgs);
|
2022-06-14 01:53:34 +01:00
|
|
|
formatter = pkgs.alejandra;
|
|
|
|
# A devshell with useful utils
|
|
|
|
devShells.default = pkgs.devshell.mkShell {
|
|
|
|
packages = [
|
|
|
|
inputs.home-manager.defaultPackage.${system}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
})));
|
|
|
|
}
|