aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix115
1 files changed, 115 insertions, 0 deletions
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..b90039d
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,115 @@
+{
+ description = "My NixOs dotfiles";
+
+ inputs = {
+ nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
+ home-manager = {
+ 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";
+ };
+ conduit = {
+ url = "gitlab:famedly/conduit";
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
+ hyprland = {
+ url = "github:hyprwm/Hyprland";
+ 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";
+ };
+ helix = {
+ url = "github:helix-editor/helix";
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
+ };
+
+ 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
+ ];
+
+ 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
+ ./share/nixos-modules/nix-config.nix
+
+ # 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;
+
+ 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 = lazygit; }
+ { package = sops; }
+ { package = config.treefmt.build.wrapper; }
+ ];
+ };
+
+ treefmt = {
+ projectRootFile = ./flake.nix;
+ programs = { nixpkgs-fmt.enable = true; };
+ };
+
+ pre-commit = {
+ check.enable = false;
+ settings = {
+ settings = { treefmt.package = config.treefmt.build.wrapper; };
+ hooks = {
+ treefmt.enable = true;
+ deadnix.enable = true;
+ };
+ };
+ }; # end of pre-commit
+ }; # end of perSystem
+ }; # end of inputs.flake-parts.lib.mkFlake
+
+ nixConfig = { };
+}