128 lines
3.6 KiB
Nix
128 lines
3.6 KiB
Nix
{
|
|
description = "Nixos config flake";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
|
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-24.05";
|
|
disko.url = "github:nix-community/disko";
|
|
disko.inputs.nixpkgs.follows = "nixpkgs";
|
|
impermanence.url = "github:nix-community/impermanence";
|
|
home-manager.url = "github:nix-community/home-manager";
|
|
home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
|
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
|
|
nix-index-database.url = "github:nix-community/nix-index-database";
|
|
nix-index-database.inputs.nixpkgs.follows = "nixpkgs";
|
|
stylix.url = "github:danth/stylix";
|
|
stylix.inputs.nixpkgs.follows = "nixpkgs";
|
|
plasma-manager.url = "github:nix-community/plasma-manager";
|
|
plasma-manager.inputs.nixpkgs.follows = "nixpkgs";
|
|
plasma-manager.inputs.home-manager.follows = "home-manager";
|
|
treefmt-nix.url = "github:numtide/treefmt-nix";
|
|
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
|
|
git-hooks.url = "github:cachix/git-hooks.nix";
|
|
git-hooks.inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
|
|
outputs =
|
|
inputs@{
|
|
nixpkgs,
|
|
self,
|
|
treefmt-nix,
|
|
...
|
|
}:
|
|
let
|
|
system = "x86_64-linux";
|
|
pkgs = import inputs.nixpkgs {
|
|
inherit system;
|
|
config.allowUnfree = true;
|
|
};
|
|
lib = import ./src/lib.nix {
|
|
inherit (nixpkgs) lib;
|
|
inherit pkgs;
|
|
inherit (inputs) home-manager;
|
|
};
|
|
createCommonArgs = system: {
|
|
inherit
|
|
self
|
|
inputs
|
|
nixpkgs
|
|
lib
|
|
pkgs
|
|
system
|
|
;
|
|
specialArgs = {
|
|
inherit self inputs;
|
|
};
|
|
};
|
|
commonArgs = createCommonArgs system;
|
|
# call with forAllSystems (commonArgs: function body)
|
|
forAllSystems =
|
|
fn:
|
|
lib.genAttrs [
|
|
"x86_64-linux"
|
|
"aarch64-linux"
|
|
"x86_64-darwin"
|
|
"aarch64-darwin"
|
|
] (system: fn (createCommonArgs system));
|
|
treefmtEval = forAllSystems (
|
|
{ pkgs, ... }:
|
|
treefmt-nix.lib.evalModule pkgs {
|
|
projectRootFile = "flake.nix";
|
|
programs.nixfmt-rfc-style.enable = true;
|
|
settings.global.excludes = [ "flake.lock" ];
|
|
}
|
|
);
|
|
in
|
|
{
|
|
inherit lib self;
|
|
nixosConfigurations = import ./src/hosts/default.nix commonArgs;
|
|
|
|
checks = forAllSystems (
|
|
{
|
|
pkgs,
|
|
system,
|
|
...
|
|
}:
|
|
{
|
|
formatting = treefmtEval.${system}.config.build.check self;
|
|
pre-commit-check = inputs.git-hooks.lib.${system}.run {
|
|
src = ./.;
|
|
excludes = [ "flake.lock" ];
|
|
hooks = {
|
|
treefmt = {
|
|
enable = true;
|
|
package = lib.mkOverride 900 treefmtEval.${system}.config.build.wrapper;
|
|
};
|
|
};
|
|
};
|
|
}
|
|
);
|
|
|
|
devShells = forAllSystems (
|
|
{
|
|
pkgs,
|
|
system,
|
|
...
|
|
}:
|
|
{
|
|
default = pkgs.mkShell {
|
|
inherit (self.checks.${system}.pre-commit-check) shellHook;
|
|
|
|
name = "dotfiles";
|
|
buildInputs = self.checks.${system}.pre-commit-check.enabledPackages;
|
|
nativeBuildInputs = [
|
|
treefmtEval.${system}.config.build.wrapper
|
|
];
|
|
packages = [
|
|
pkgs.sops
|
|
pkgs.ssh-to-age
|
|
pkgs.nixfmt-rfc-style
|
|
];
|
|
DIRENV_LOG_FORMAT = "";
|
|
};
|
|
}
|
|
);
|
|
|
|
formatter = forAllSystems ({ system, ... }: treefmtEval.${system}.config.build.wrapper);
|
|
};
|
|
}
|