dotfiles/flake.nix

96 lines
3.0 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";
nixgl.url = "github:guibou/nixGL";
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;
};
};
outputs = {
nixpkgs, agenix, home-manager, flake-utils, nixgl, rust-overlay, flake-compat
,...
}@_inputs: let
# Context/global stuffs to be passed down
# TODO: adapt to different platforms think about different systems later
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
config = {
allowUnfree = true;
};
};
# inject nixpkgs.lib onto c_ (calculus)
_lib = pkgs.lib;
inputs = (_lib.recursiveUpdate {
inherit system;
# NOTE: this will only read files that are within git tree
# all secrets should go into secrets.nix and secrets/*.age
2022-12-27 04:22:07 +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";
};
} _inputs);
2022-12-27 05:58:24 +00:00
inputs_w_pkgs = (_lib.recursiveUpdate {inherit pkgs; lib = pkgs.lib;} inputs);
2022-12-25 09:55:30 +00:00
lib = _lib.recursiveUpdate (import ./lib inputs_w_pkgs) _lib;
# update inputs with our library and past onto our end configurations
inputs_w_lib = (lib.recursiveUpdate {inherit lib;} inputs_w_pkgs);
2022-12-25 09:55:30 +00:00
modules = (import ./modules inputs_w_lib);
hosts = (import ./hosts inputs_w_lib);
users = (import ./users inputs_w_lib);
2022-12-27 04:22:07 +00:00
# {nixpkgs, agenix, home-manager, flake-utils, nixgl, rust-overlay, flake-compat
# ,pkgs, lib (extended), proj_root}
2022-12-25 09:55:30 +00:00
final_inputs = inputs_w_lib;
2022-12-27 05:58:24 +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-25 09:55:30 +00:00
in {
2022-12-27 04:22:07 +00:00
inherit (hosts) nixosConfigurations;
2022-12-25 09:55:30 +00:00
# inherit (users) homeConfigurations;
2022-12-27 04:22:07 +00:00
inherit lib;
devShell."${system}" = import ./dev-shell.nix final_inputs;
2022-12-27 04:22:07 +00:00
templates = import ./templates final_inputs;
2022-12-27 05:58:24 +00:00
unit_tests = lib.runTests unit_tests;
2022-12-27 04:22:07 +00:00
secrets = import ./secrets final_inputs;
2022-12-27 05:58:24 +00:00
debug = {
inherit final_inputs hosts users modules lib inputs_w_pkgs unit_tests;
};
2022-12-25 09:55:30 +00:00
};
}