aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
authorMiran Bastaja <miran.bastaja04@gmail.com>2024-07-06 06:43:24 +0200
committerMiran Bastaja <miran.bastaja04@gmail.com>2024-07-06 06:43:24 +0200
commitdac5f403855f4fa15bb5e50c76949e038a3679cc (patch)
tree196e8c3fc674c5e7dd299d882c5452308ede7f64 /flake.nix
parent333f134ec64739abf0c3e46e59a4a8ad88b883b5 (diff)
Simplify flake
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix118
1 files changed, 35 insertions, 83 deletions
diff --git a/flake.nix b/flake.nix
index c5bcc5e..72f753e 100644
--- a/flake.nix
+++ b/flake.nix
@@ -3,6 +3,7 @@
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
+ flake-utils.url = "github:numtide/flake-utils";
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
@@ -11,29 +12,13 @@
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
- flake-parts.url = "github:hercules-ci/flake-parts";
- devshell = {
- url = "github:numtide/devshell";
- inputs.nixpkgs.follows = "nixpkgs";
- };
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
- treefmt-nix = {
- url = "github:numtide/treefmt-nix";
- inputs.nixpkgs.follows = "nixpkgs";
- };
- pre-commit-hooks-nix = {
- url = "github:cachix/pre-commit-hooks.nix";
- inputs.nixpkgs.follows = "nixpkgs";
- };
sorre-website = {
url = "git+https://codeberg.org/miranb/sorre-website.git";
inputs.nixpkgs.follows = "nixpkgs";
- inputs.flake-parts.follows = "flake-parts";
- inputs.devshell.follows = "devshell";
- inputs.treefmt-nix.follows = "treefmt-nix";
};
snippets-ls = {
url = "github:quantonganh/snippets-ls";
@@ -41,75 +26,42 @@
};
};
- outputs = inputs@{ flake-parts, ... }:
- inputs.flake-parts.lib.mkFlake { inherit inputs; } {
- systems = [ "x86_64-linux" ];
- imports = [
- inputs.devshell.flakeModule
- inputs.treefmt-nix.flakeModule
- inputs.pre-commit-hooks-nix.flakeModule
- ];
+ outputs = { flake-utils, ... }@inputs:
+ flake-utils.lib.eachDefaultSystem (system:
+ let pkgs = inputs.nixpkgs.legacyPackages.${system};
+ in {
+ formatter = pkgs.nixfmt;
+ devShells.default =
+ pkgs.mkShell { buildInputs = with pkgs; [ git gitui sops ]; };
+ }) // {
+ nixosConfigurations = let
+ generateNixosConfig = name: _value: {
+ system =
+ "x86_64-linux"; # I don't have any other type of machine yet
+ modules = with inputs; [
+ home-manager.nixosModules.home-manager
+ sops-nix.nixosModules.sops
+ disko.nixosModules.disko
+ ./share/system/common.nix
- flake.nixosConfigurations = let
- generateNixosConfig = name: _value: {
- system = "x86_64-linux"; # I don't have any other type of machine yet
- modules = [
- inputs.home-manager.nixosModules.home-manager
- inputs.sops-nix.nixosModules.sops
- inputs.disko.nixosModules.disko
- ./share/system/common.nix
-
- # This directory has to exist and have a `default.nix` in it, see
- # `./hosts` directory for examples
- ./hosts/${name}
- ];
- specialArgs = {
- inherit inputs;
- flakeRoot = ./.;
+ # This directory has to exist and have a `default.nix` in it, see
+ # `./hosts` directory for examples
+ ./hosts/${name}
+ ];
+ specialArgs = {
+ inherit inputs;
+ flakeRoot = ./.;
+ };
};
- };
- # wrapper around nixpkgs.lib.nixosSystem to enable using it on attrsets
- generateNixosSystem = _name: value:
- inputs.nixpkgs.lib.nixosSystem value;
+ # wrapper around nixpkgs.lib.nixosSystem to enable using it on attrsets
+ generateNixosSystem = _name: value:
+ inputs.nixpkgs.lib.nixosSystem value;
- hosts = builtins.readDir ./hosts;
- nixosConfigs = builtins.mapAttrs generateNixosConfig hosts;
- # If you want to add something to a particular system, do it here before
- # the `in ...` line
+ hosts = builtins.readDir ./hosts;
+ nixosConfigs = builtins.mapAttrs generateNixosConfig hosts;
+ # If you want to add something to a particular system, do it here before
+ # the `in ...` line
- in builtins.mapAttrs generateNixosSystem nixosConfigs;
-
- perSystem = { pkgs, config, ... }: {
- devshells.default = {
- name = "nixconf-sh";
-
- devshell.startup.pre-commit-install.text =
- config.pre-commit.installationScript;
-
- packages = (builtins.attrValues config.treefmt.build.programs);
- commands = with pkgs; [
- { package = git; }
- { package = gitui; }
- { package = sops; }
- { package = config.treefmt.build.wrapper; }
- ];
- };
-
- treefmt = {
- projectRootFile = ./flake.nix;
- programs = { nixfmt.enable = true; };
- };
-
- pre-commit = {
- check.enable = false;
- settings = {
- hooks = {
- treefmt.enable = true;
- treefmt.package = config.treefmt.build.wrapper;
- deadnix.enable = true;
- };
- };
- }; # end of pre-commit
- }; # end of perSystem
- }; # end of inputs.flake-parts.lib.mkFlake
+ in builtins.mapAttrs generateNixosSystem nixosConfigs;
+ };
}