refactor(flake): hand roll flake

dev-docs
Moritz Böhme 2023-05-11 21:48:38 +02:00
parent 9567cce5fa
commit bd88d8382c
Signed by: moritz
GPG Key ID: 970C6E89EB0547A9
5 changed files with 89 additions and 100 deletions

View File

@ -980,8 +980,7 @@
"nvim-treesitter-textsubjects": "nvim-treesitter-textsubjects",
"pre-commit-hooks": "pre-commit-hooks",
"smartcolumn-nvim": "smartcolumn-nvim",
"stable": "stable",
"utils": "utils"
"stable": "stable"
}
},
"rust-overlay": {
@ -1083,26 +1082,6 @@
"type": "github"
}
},
"utils": {
"inputs": {
"flake-utils": [
"flake-utils"
]
},
"locked": {
"lastModified": 1657226504,
"narHash": "sha256-GIYNjuq4mJlFgqKsZ+YrgzWm0IpA4axA3MCrdKYj7gs=",
"owner": "gytis-ivaskevicius",
"repo": "flake-utils-plus",
"rev": "2bf0f91643c2e5ae38c1b26893ac2927ac9bd82a",
"type": "github"
},
"original": {
"owner": "gytis-ivaskevicius",
"repo": "flake-utils-plus",
"type": "github"
}
},
"wlroots": {
"flake": false,
"locked": {

152
flake.nix
View File

@ -13,8 +13,6 @@
stable.url = "github:nixos/nixpkgs/nixos-22.11";
flake-utils.url = "github:numtide/flake-utils";
utils.url = "github:gytis-ivaskevicius/flake-utils-plus";
utils.inputs.flake-utils.follows = "flake-utils";
agenix.inputs.nixpkgs.follows = "nixpkgs";
agenix.url = "github:ryantm/agenix";
@ -79,50 +77,51 @@
Outputs
*/
outputs =
inputs@{ self, nixpkgs, utils, ... }:
utils.lib.mkFlake {
inherit self inputs;
outputs = inputs@{ self, nixpkgs, ... }:
let
systems = [ "x86_64-linux" "aarch64-linux" ];
supportedSystems = [ "x86_64-linux" ];
channelsConfig.allowUnfree = true;
forEachSystem = lib.genAttrs systems;
lib = nixpkgs.lib.extend
(self: _: { my = import ./lib { lib = self; }; });
/*
Overlays
*/
overlay = import ./overlays {
inherit inputs;
inherit (self) lib;
};
channels.nixpkgs.overlaysBuilder = _: [
config.allowUnfree = true;
overlays = [
inputs.hypr-contrib.overlays.default
inputs.hyprland.overlays.default
inputs.neovim-nightly-overlay.overlay
inputs.utils.overlay
self.overlay
overlay
];
overlays = utils.lib.exportOverlays
{
inherit (self) pkgs inputs;
} // {
default = self.overlay;
pkgsFor = system: import nixpkgs {
inherit system config;
overlays = overlays ++ [
(
_: prev: {
master = import inputs.master {
inherit (prev) system;
inherit overlays config;
};
stable = import inputs.stable {
inherit (prev) system;
inherit overlays config;
};
}
)
overlay
];
};
/*
Modules
*/
hostDefaults.modules = [
./modules/default.nix
defaultModules = [
{ nixpkgs = { inherit config; }; }
./modules
inputs.home-manager.nixosModule
{
home-manager = {
@ -134,45 +133,66 @@
inputs.agenix.nixosModules.age
];
hosts.nixos-laptop.modules = [
./hosts/nixos-laptop
];
hosts.nixos-desktop.modules = [
./hosts/nixos-desktop
];
/*
Other Outputs
*/
outputsBuilder = channels:
with channels.nixpkgs; {
devShells.default = mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
name = "dotfiles";
packages = [
# Secrets
pkgs.agenix
# cachix
cachix
];
};
checks.pre-commit-check = inputs.pre-commit-hooks.lib."${system}".run {
src = ./.;
hooks = {
nixpkgs-fmt.enable = true;
statix.enable = true;
shellcheck.enable = true;
stylua.enable = true;
hosts = self.lib.my.mapModules
(path:
let
system = import "${path}/system.nix";
pkgs = pkgsFor system;
in
lib.nixosSystem {
inherit pkgs system lib;
specialArgs = {
inherit inputs;
};
};
modules = defaultModules ++ [ path ];
})
./hosts;
packages = utils.lib.exportPackages self.overlays channels;
pre-commit-check = system: inputs.pre-commit-hooks.lib."${system}".run {
src = ./.;
hooks = {
nixpkgs-fmt.enable = true;
statix.enable = true;
shellcheck.enable = true;
stylua.enable = true;
};
};
in
with lib; {
inherit lib;
pkgs = genAttrs systems pkgsFor;
# ╔══════════════════════════════════════════════════════════╗
# ║ NixOS Configurations ║
# ╚══════════════════════════════════════════════════════════╝
nixosConfigurations = hosts;
# ╔══════════════════════════════════════════════════════════╗
# ║ Other Outputs ║
# ╚══════════════════════════════════════════════════════════╝
devShells = forEachSystem (system:
let
pkgs = pkgsFor system;
in
{
default = pkgs.mkShell
{
inherit (pre-commit-check system) shellHook;
name = "dotfiles";
packages = with pkgs; [
# Secrets
agenix
# cachix
cachix
];
};
});
checks = forEachSystem (system: {
pre-commit-check = pre-commit-check system;
});
};
}

View File

@ -0,0 +1 @@
"x86_64-linux"

View File

@ -0,0 +1 @@
"x86_64-linux"

View File

@ -1,12 +0,0 @@
{ inputs, ... }:
_: prev: {
master = import inputs.master {
inherit (prev) system;
config.allowUnfree = true;
};
stable = import inputs.stable {
inherit (prev) system;
config.allowUnfree = true;
};
}