dotfiles/flake.nix

129 lines
3.8 KiB
Nix
Raw Normal View History

2022-12-25 09:55:30 +00:00
{
description = "My personal configuration in Nix (and some native configurations)";
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
agenix = {
url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
2023-01-03 20:10:04 +00:00
nixgl.url = "path:out-of-tree/nixGL";
2022-12-25 09:55:30 +00:00
rust-overlay.url = "github:oxalica/rust-overlay";
# Allows default.nix to call onto flake.nix. Useful for nix eval and automations
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
kpcli-py = {
url = "github:rebkwok/kpcli";
flake = false;
};
2023-01-10 15:30:52 +00:00
neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay";
2022-12-25 09:55:30 +00:00
};
2023-01-12 18:42:20 +00:00
outputs =
{ nixpkgs
, agenix
, home-manager
, flake-utils
, nixgl
, rust-overlay
, flake-compat
, neovim-nightly-overlay
, ...
}@_inputs:
let
# Context/global stuffs to be passed down
# NOTE: this will only read files that are within git tree
# all secrets should go into secrets.nix and secrets/*.age
2023-01-12 18:42:20 +00:00
proj_root =
let
path = builtins.toString ./.;
in
{
inherit path;
configs.path = "${path}/native_configs";
scripts.path = "${path}/scripts";
secrets.path = "${path}/secrets";
testdata.path = "${path}/tests";
modules.path = "${path}/modules";
hosts.path = "${path}/hosts";
users.path = "${path}/users";
};
# TODO: adapt to different platforms think about different systems later
system = "x86_64-linux";
overlays = [
rust-overlay.overlays.default
(self: pkgs@{ lib, ... }: {
lib = pkgs.lib // (import ./lib (_inputs // { inherit pkgs proj_root; }));
})
];
pkgs = import nixpkgs {
inherit system;
overlays = import ./overlays.nix _inputs;
config = {
allowUnfree = true;
};
2022-12-27 04:22:07 +00:00
};
2023-01-12 18:42:20 +00:00
# now, this lib is extremely powerful as it also engulfs nixpkgs.lib
# lib = nixpkgs.lib // pkgs.lib;
lib = (builtins.foldl' (lhs: rhs: (nixpkgs.lib.recursiveUpdate lhs rhs)) { } [
nixpkgs.lib
pkgs.lib
(import ./lib {
inherit proj_root pkgs overlays system;
inherit (pkgs) lib;
})
]);
inputs_w_lib = (pkgs.lib.recursiveUpdate _inputs {
inherit system proj_root pkgs lib;
});
2022-12-25 09:55:30 +00:00
2023-01-12 18:42:20 +00:00
modules = (import ./modules inputs_w_lib);
hosts = (import ./hosts inputs_w_lib);
users = (import ./users inputs_w_lib);
2022-12-27 05:58:24 +00:00
2023-01-12 18:42:20 +00:00
# {nixpkgs, agenix, home-manager, flake-utils, nixgl, rust-overlay, flake-compat
# ,pkgs, lib (extended), proj_root}
final_inputs = inputs_w_lib;
2022-12-27 05:58:24 +00:00
2023-01-12 18:42:20 +00:00
# Tests: unit + integration
unit_tests = (import ./lib/test.nix final_inputs) //
{
test_example = {
expr = "names must start with 'test'";
expected = "or won't show up";
};
not_show = {
expr = "this will be ignored by lib.runTests";
expected = "for sure";
};
2022-12-27 05:58:24 +00:00
};
2023-01-12 18:42:20 +00:00
secrets = import ./secrets final_inputs;
in
{
inherit (hosts) nixosConfigurations;
inherit (users) homeConfigurations;
inherit lib proj_root;
devShell."${system}" = import ./dev-shell.nix final_inputs;
templates = import ./templates final_inputs;
secrets = {
pubKeys = {
hosts = hosts.pubKeys;
users = users.pubKeys;
2022-12-27 05:58:24 +00:00
};
};
2023-01-12 18:42:20 +00:00
unit_tests = lib.runTests unit_tests;
debug = {
inherit final_inputs hosts users modules lib inputs_w_lib unit_tests pkgs nixpkgs;
2023-01-12 17:50:46 +00:00
};
2023-01-13 06:42:21 +00:00
formatter."${system}" = pkgs.nixpkgs-fmt;
2022-12-27 05:58:24 +00:00
};
2022-12-25 09:55:30 +00:00
}