2022-02-06 00:06:26 +00:00
|
|
|
{
|
|
|
|
description = "System configs";
|
|
|
|
|
|
|
|
inputs = {
|
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
2022-02-14 20:44:59 +00:00
|
|
|
devshell.url = "github:numtide/devshell";
|
|
|
|
devshell.inputs.nixpkgs.follows = "nixpkgs-unstable";
|
2022-02-15 20:50:27 +00:00
|
|
|
|
|
|
|
nixpkgs-master.url = "nixpkgs";
|
2022-02-06 00:06:26 +00:00
|
|
|
nixpkgs-unstable.url = "nixpkgs/nixos-unstable";
|
|
|
|
nixpkgs-stable.url = "nixpkgs/nixos-21.11";
|
2022-02-16 01:40:03 +00:00
|
|
|
nixpkgs-mine.url = "github:devplayer0/nixpkgs";
|
|
|
|
|
2022-02-15 20:50:27 +00:00
|
|
|
home-manager-unstable.url = "home-manager";
|
|
|
|
home-manager-unstable.inputs.nixpkgs.follows = "nixpkgs-unstable";
|
|
|
|
home-manager-stable.url = "home-manager/release-21.11";
|
|
|
|
home-manager-stable.inputs.nixpkgs.follows = "nixpkgs-stable";
|
2022-02-06 00:06:26 +00:00
|
|
|
|
2022-02-11 01:15:24 +00:00
|
|
|
# Stuff used by the flake for build / deployment
|
2022-02-06 00:06:26 +00:00
|
|
|
agenix.url = "github:ryantm/agenix";
|
|
|
|
agenix.inputs.nixpkgs.follows = "nixpkgs-unstable";
|
|
|
|
deploy-rs.url = "github:serokell/deploy-rs";
|
|
|
|
deploy-rs.inputs.nixpkgs.follows = "nixpkgs-unstable";
|
2022-02-11 01:15:24 +00:00
|
|
|
|
|
|
|
# Stuff used by systems
|
|
|
|
#impermanence.url = "github:nix-community/impermanence";
|
|
|
|
impermanence.url = "github:devplayer0/impermanence/qemu-vm-dirs";
|
2022-02-06 00:06:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
outputs =
|
|
|
|
inputs@{
|
|
|
|
self,
|
|
|
|
|
|
|
|
flake-utils,
|
|
|
|
|
2022-02-16 01:40:03 +00:00
|
|
|
nixpkgs-master, nixpkgs-unstable, nixpkgs-stable, nixpkgs-mine,
|
2022-02-15 20:50:27 +00:00
|
|
|
home-manager-unstable, home-manager-stable,
|
2022-02-06 00:06:26 +00:00
|
|
|
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
let
|
2022-02-13 17:44:14 +00:00
|
|
|
inherit (builtins) mapAttrs attrValues;
|
|
|
|
inherit (lib.flake) eachDefaultSystem;
|
2022-02-14 20:44:59 +00:00
|
|
|
inherit (lib.my) attrsToList mkApp mkShellApp mkShellApp' inlineModules mkDefaultSystemsPkgs flakePackageOverlay;
|
2022-02-06 00:06:26 +00:00
|
|
|
|
2022-02-15 20:50:27 +00:00
|
|
|
# Extend a lib with extras that _must not_ internally reference private nixpkgs. flake-utils doesn't, but many
|
|
|
|
# other flakes (e.g. home-manager) probably do internally.
|
|
|
|
libOverlay = final: prev: {
|
2022-02-15 20:58:03 +00:00
|
|
|
my = import ./lib.nix { lib = final; };
|
2022-02-06 00:06:26 +00:00
|
|
|
flake = flake-utils.lib;
|
2022-02-15 20:50:27 +00:00
|
|
|
};
|
|
|
|
pkgsLibOverlay = final: prev: { lib = prev.lib.extend libOverlay; };
|
2022-02-06 00:06:26 +00:00
|
|
|
|
2022-02-15 20:50:27 +00:00
|
|
|
# Override the flake-level lib since we're going to use it for non-config specific stuff
|
|
|
|
pkgsFlakes = mapAttrs (_: pkgsFlake: pkgsFlake // { lib = pkgsFlake.lib.extend libOverlay; }) {
|
|
|
|
master = nixpkgs-master;
|
2022-02-06 00:06:26 +00:00
|
|
|
unstable = nixpkgs-unstable;
|
|
|
|
stable = nixpkgs-stable;
|
2022-02-16 01:40:03 +00:00
|
|
|
mine = nixpkgs-mine;
|
2022-02-06 00:06:26 +00:00
|
|
|
};
|
2022-02-15 20:50:27 +00:00
|
|
|
hmFlakes = {
|
|
|
|
unstable = home-manager-unstable;
|
|
|
|
stable = home-manager-stable;
|
|
|
|
};
|
2022-02-06 00:06:26 +00:00
|
|
|
|
2022-02-15 20:50:27 +00:00
|
|
|
# Should only be used for platform-independent flake stuff! This should never leak into a NixOS or home-manager
|
|
|
|
# config - they'll get their own.
|
2022-02-06 00:06:26 +00:00
|
|
|
lib = pkgsFlakes.unstable.lib;
|
|
|
|
|
2022-02-15 20:50:27 +00:00
|
|
|
# pkgs for dev shell etc
|
2022-02-13 14:28:49 +00:00
|
|
|
pkgs' = mapAttrs
|
2022-02-13 23:06:31 +00:00
|
|
|
(_: path: mkDefaultSystemsPkgs path (system: {
|
2022-02-13 14:28:49 +00:00
|
|
|
overlays = [
|
2022-02-15 20:50:27 +00:00
|
|
|
pkgsLibOverlay
|
2022-02-14 20:44:59 +00:00
|
|
|
inputs.devshell.overlay
|
2022-02-13 14:28:49 +00:00
|
|
|
inputs.agenix.overlay
|
|
|
|
inputs.deploy-rs.overlay
|
2022-02-15 20:50:27 +00:00
|
|
|
(flakePackageOverlay inputs.home-manager-unstable system)
|
2022-02-13 14:28:49 +00:00
|
|
|
];
|
2022-02-13 23:06:31 +00:00
|
|
|
}))
|
|
|
|
pkgsFlakes;
|
|
|
|
|
|
|
|
# Easiest to build the basic pkgs here (with our lib overlay too)
|
2022-02-15 20:50:27 +00:00
|
|
|
configPkgs' = mapAttrs
|
2022-02-13 23:06:31 +00:00
|
|
|
(_: path: mkDefaultSystemsPkgs path (_: {
|
|
|
|
overlays = [
|
2022-02-15 20:50:27 +00:00
|
|
|
pkgsLibOverlay
|
2022-02-13 23:06:31 +00:00
|
|
|
];
|
|
|
|
}))
|
2022-02-13 14:28:49 +00:00
|
|
|
pkgsFlakes;
|
2022-02-13 17:44:14 +00:00
|
|
|
|
2022-02-17 15:47:24 +00:00
|
|
|
modules = mapAttrs (_: f: ./. + "/nixos/modules/${f}") {
|
2022-02-13 17:44:14 +00:00
|
|
|
common = "common.nix";
|
|
|
|
build = "build.nix";
|
|
|
|
dynamic-motd = "dynamic-motd.nix";
|
|
|
|
tmproot = "tmproot.nix";
|
|
|
|
firewall = "firewall.nix";
|
|
|
|
server = "server.nix";
|
|
|
|
};
|
2022-02-17 15:47:24 +00:00
|
|
|
homeModules = mapAttrs (_: f: ./. + "/home-manager/modules/${f}") {
|
2022-02-13 23:06:31 +00:00
|
|
|
common = "common.nix";
|
2022-02-15 01:08:00 +00:00
|
|
|
gui = "gui.nix";
|
2022-02-13 23:06:31 +00:00
|
|
|
};
|
2022-02-13 13:10:21 +00:00
|
|
|
in
|
2022-02-13 14:28:49 +00:00
|
|
|
# Platform independent stuff
|
2022-02-13 13:10:21 +00:00
|
|
|
{
|
2022-02-13 14:28:49 +00:00
|
|
|
lib = lib.my;
|
2022-02-13 17:44:14 +00:00
|
|
|
nixpkgs = pkgs';
|
2022-02-06 00:06:26 +00:00
|
|
|
|
2022-02-13 23:06:31 +00:00
|
|
|
nixosModules = inlineModules modules;
|
|
|
|
homeModules = inlineModules homeModules;
|
2022-02-06 00:06:26 +00:00
|
|
|
|
2022-02-17 15:47:24 +00:00
|
|
|
nixosConfigurations = import ./nixos {
|
2022-02-15 20:50:27 +00:00
|
|
|
inherit lib pkgsFlakes hmFlakes inputs;
|
|
|
|
pkgs' = configPkgs';
|
2022-02-13 23:06:31 +00:00
|
|
|
modules = attrValues modules;
|
|
|
|
homeModules = attrValues homeModules;
|
|
|
|
};
|
2022-02-11 01:15:24 +00:00
|
|
|
systems = mapAttrs (_: system: system.config.system.build.toplevel) self.nixosConfigurations;
|
2022-02-17 15:47:24 +00:00
|
|
|
vms = mapAttrs (_: system: system.config.my.buildAs.devVM) self.nixosConfigurations;
|
|
|
|
isos = mapAttrs (_: system: system.config.my.buildAs.iso) self.nixosConfigurations;
|
2022-02-13 23:06:31 +00:00
|
|
|
|
2022-02-17 15:47:24 +00:00
|
|
|
homeConfigurations = import ./home-manager {
|
2022-02-15 20:50:27 +00:00
|
|
|
inherit lib hmFlakes inputs;
|
|
|
|
pkgs' = configPkgs';
|
2022-02-13 23:06:31 +00:00
|
|
|
modules = attrValues homeModules;
|
|
|
|
};
|
|
|
|
homes = mapAttrs(_: home: home.activationPackage) self.homeConfigurations;
|
2022-02-13 14:28:49 +00:00
|
|
|
} //
|
|
|
|
(eachDefaultSystem (system:
|
|
|
|
let
|
2022-02-14 00:56:43 +00:00
|
|
|
homeFlake = "$HOME/.config/nixpkgs/flake.nix";
|
|
|
|
|
2022-02-13 14:28:49 +00:00
|
|
|
pkgs = pkgs'.unstable.${system};
|
|
|
|
lib = pkgs.lib;
|
|
|
|
in
|
|
|
|
# Stuff for each platform
|
|
|
|
{
|
2022-02-14 20:44:59 +00:00
|
|
|
devShell = pkgs.devshell.mkShell {
|
|
|
|
env = attrsToList {
|
|
|
|
# starship will show this
|
|
|
|
name = "devshell";
|
2022-02-14 00:56:43 +00:00
|
|
|
|
2022-02-14 20:44:59 +00:00
|
|
|
NIX_USER_CONF_FILES = toString (pkgs.writeText "nix.conf"
|
|
|
|
''
|
|
|
|
experimental-features = nix-command flakes ca-derivations
|
|
|
|
'');
|
2022-02-14 00:56:43 +00:00
|
|
|
};
|
2022-02-13 18:47:35 +00:00
|
|
|
|
2022-02-13 14:28:49 +00:00
|
|
|
packages = with pkgs; [
|
2022-02-14 20:44:59 +00:00
|
|
|
coreutils
|
2022-02-17 15:59:00 +00:00
|
|
|
nixVersions.stable
|
2022-02-13 14:28:49 +00:00
|
|
|
agenix
|
|
|
|
deploy-rs.deploy-rs
|
2022-02-13 23:06:31 +00:00
|
|
|
home-manager
|
2022-02-13 14:28:49 +00:00
|
|
|
];
|
2022-02-14 20:44:59 +00:00
|
|
|
|
|
|
|
commands = [
|
2022-02-15 00:12:10 +00:00
|
|
|
{
|
|
|
|
name = "repl";
|
|
|
|
category = "utilities";
|
|
|
|
help = "Open a `nix repl` with this flake";
|
2022-02-15 02:38:35 +00:00
|
|
|
command =
|
|
|
|
''
|
|
|
|
tmp="$(mktemp --tmpdir repl.nix.XXXXX)"
|
|
|
|
echo "builtins.getFlake \"$PRJ_ROOT\"" > "$tmp"
|
|
|
|
nix repl "$tmp" || true
|
|
|
|
rm "$tmp"
|
|
|
|
'';
|
2022-02-15 00:12:10 +00:00
|
|
|
}
|
2022-02-14 20:44:59 +00:00
|
|
|
{
|
|
|
|
name = "home-link";
|
|
|
|
category = "utilities";
|
|
|
|
help = "Install link to flake.nix for home-manager to use";
|
|
|
|
command =
|
|
|
|
''
|
|
|
|
[ -e "${homeFlake}" ] && echo "${homeFlake} already exists" && exit 1
|
|
|
|
|
|
|
|
mkdir -p "$(dirname "${homeFlake}")"
|
|
|
|
ln -s "$(pwd)/flake.nix" "${homeFlake}"
|
|
|
|
echo "Installed link to $(pwd)/flake.nix at ${homeFlake}"
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "home-unlink";
|
|
|
|
category = "utilities";
|
|
|
|
help = "Remove home-manager flake.nix link";
|
|
|
|
command = "rm -f ${homeFlake}";
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
name = "fmt";
|
|
|
|
category = "tasks";
|
|
|
|
help = pkgs.nixpkgs-fmt.meta.description;
|
|
|
|
command = ''exec "${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt" "$@"'';
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "home-switch";
|
|
|
|
category = "tasks";
|
|
|
|
help = "Run `home-manager switch`";
|
|
|
|
command = ''home-manager switch --flake . "$@"'';
|
|
|
|
}
|
|
|
|
];
|
2022-02-13 14:28:49 +00:00
|
|
|
};
|
|
|
|
}));
|
2022-02-06 00:06:26 +00:00
|
|
|
}
|