From f842c9233914028ad11aa41389a95313a911b08a Mon Sep 17 00:00:00 2001 From: Filippo Berto Date: Mon, 21 Oct 2024 11:44:35 +0200 Subject: [PATCH] Basic flake --- flake.lock | 217 +++++++---- flake.nix | 1029 +++++++++++++++++++++++++++------------------------- 2 files changed, 669 insertions(+), 577 deletions(-) diff --git a/flake.lock b/flake.lock index 8da55f1..c78fa6e 100644 --- a/flake.lock +++ b/flake.lock @@ -100,11 +100,11 @@ "flake-compat_3": { "flake": false, "locked": { - "lastModified": 1673956053, - "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", "owner": "edolstra", "repo": "flake-compat", - "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", "type": "github" }, "original": { @@ -132,11 +132,11 @@ "flake-compat_5": { "flake": false, "locked": { - "lastModified": 1696426674, - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", "owner": "edolstra", "repo": "flake-compat", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", "type": "github" }, "original": { @@ -145,6 +145,24 @@ "type": "github" } }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1727826117, + "narHash": "sha256-K5ZLCyfO/Zj9mPFldf3iwS6oZStJcU4tSpiXTMYaaL0=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "3d04084d54bedc3d6b8b736c70ef449225c361b1", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems_3" @@ -181,7 +199,49 @@ "type": "github" } }, + "git-hooks-nix": { + "inputs": { + "flake-compat": "flake-compat_3", + "gitignore": "gitignore", + "nixpkgs": "nixpkgs", + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1729104314, + "narHash": "sha256-pZRZsq5oCdJt3upZIU4aslS9XwFJ+/nVtALHIciX/BI=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "3c3e88f0f544d6bb54329832616af7eb971b6be6", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, "gitignore": { + "inputs": { + "nixpkgs": [ + "git-hooks-nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "gitignore_2": { "inputs": { "nixpkgs": [ "nix-rice", @@ -203,27 +263,6 @@ "type": "github" } }, - "gitignore_2": { - "inputs": { - "nixpkgs": [ - "pre-commit-hooks", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1709087332, - "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", - "owner": "hercules-ci", - "repo": "gitignore.nix", - "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "gitignore.nix", - "type": "github" - } - }, "home-manager": { "inputs": { "nixpkgs": [ @@ -304,10 +343,10 @@ }, "nix-rice": { "inputs": { - "flake-compat": "flake-compat_3", + "flake-compat": "flake-compat_4", "flake-utils": "flake-utils_2", "kitty-themes-src": "kitty-themes-src", - "nixpkgs-lib": "nixpkgs-lib", + "nixpkgs-lib": "nixpkgs-lib_2", "pre-commit-hooks": "pre-commit-hooks" }, "locked": { @@ -377,21 +416,33 @@ }, "nixpkgs": { "locked": { - "lastModified": 1681303793, - "narHash": "sha256-JEdQHsYuCfRL2PICHlOiH/2ue3DwoxUX7DJ6zZxZXFk=", + "lastModified": 1719082008, + "narHash": "sha256-jHJSUH619zBQ6WdC21fFAlDxHErKVDJ5fpN0Hgx4sjs=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "fe2ecaf706a5907b5e54d979fbde4924d84b65fc", + "rev": "9693852a2070b398ee123a329e68f0dab5526681", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-unstable", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } }, "nixpkgs-lib": { + "locked": { + "lastModified": 1727825735, + "narHash": "sha256-0xHYkMkeLVQAMa7gvkddbPqpxph+hDzdu1XdGPJR+Os=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz" + } + }, + "nixpkgs-lib_2": { "locked": { "lastModified": 1681001314, "narHash": "sha256-5sDnCLdrKZqxLPK4KA8+f4A3YKO/u6ElpMILvX0g72c=", @@ -407,22 +458,6 @@ } }, "nixpkgs-stable": { - "locked": { - "lastModified": 1678872516, - "narHash": "sha256-/E1YwtMtFAu2KUQKV/1+KFuReYPANM2Rzehk84VxVoc=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "9b8e5abb18324c7fe9f07cb100c3cd4a29cda8b8", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-22.11", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-stable_2": { "locked": { "lastModified": 1720386169, "narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=", @@ -438,6 +473,22 @@ "type": "github" } }, + "nixpkgs-stable_2": { + "locked": { + "lastModified": 1678872516, + "narHash": "sha256-/E1YwtMtFAu2KUQKV/1+KFuReYPANM2Rzehk84VxVoc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9b8e5abb18324c7fe9f07cb100c3cd4a29cda8b8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-22.11", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs-u": { "locked": { "lastModified": 1729256560, @@ -455,6 +506,22 @@ } }, "nixpkgs_2": { + "locked": { + "lastModified": 1681303793, + "narHash": "sha256-JEdQHsYuCfRL2PICHlOiH/2ue3DwoxUX7DJ6zZxZXFk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "fe2ecaf706a5907b5e54d979fbde4924d84b65fc", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { "locked": { "lastModified": 1729357638, "narHash": "sha256-66RHecx+zohbZwJVEPF7uuwHeqf8rykZTMCTqIrOew4=", @@ -472,14 +539,14 @@ }, "pre-commit-hooks": { "inputs": { - "flake-compat": "flake-compat_4", + "flake-compat": "flake-compat_5", "flake-utils": [ "nix-rice", "flake-utils" ], - "gitignore": "gitignore", - "nixpkgs": "nixpkgs", - "nixpkgs-stable": "nixpkgs-stable" + "gitignore": "gitignore_2", + "nixpkgs": "nixpkgs_2", + "nixpkgs-stable": "nixpkgs-stable_2" }, "locked": { "lastModified": 1682596858, @@ -495,43 +562,22 @@ "type": "github" } }, - "pre-commit-hooks_2": { - "inputs": { - "flake-compat": "flake-compat_5", - "gitignore": "gitignore_2", - "nixpkgs": [ - "nixpkgs" - ], - "nixpkgs-stable": "nixpkgs-stable_2" - }, - "locked": { - "lastModified": 1729104314, - "narHash": "sha256-pZRZsq5oCdJt3upZIU4aslS9XwFJ+/nVtALHIciX/BI=", - "owner": "cachix", - "repo": "pre-commit-hooks.nix", - "rev": "3c3e88f0f544d6bb54329832616af7eb971b6be6", - "type": "github" - }, - "original": { - "owner": "cachix", - "repo": "pre-commit-hooks.nix", - "type": "github" - } - }, "root": { "inputs": { "agenix": "agenix", "deploy-rs": "deploy-rs", "flake-compat": "flake-compat_2", + "flake-parts": "flake-parts", "flake-utils": "flake-utils", + "git-hooks-nix": "git-hooks-nix", "home-manager": "home-manager_2", "home-manager-u": "home-manager-u", "nix-rice": "nix-rice", "nixos-generators": "nixos-generators", "nixos-hardware": "nixos-hardware", - "nixpkgs": "nixpkgs_2", + "nixpkgs": "nixpkgs_3", "nixpkgs-u": "nixpkgs-u", - "pre-commit-hooks": "pre-commit-hooks_2" + "systems": "systems_5" } }, "systems": { @@ -594,6 +640,21 @@ "type": "github" } }, + "systems_5": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "utils": { "inputs": { "systems": "systems_2" diff --git a/flake.nix b/flake.nix index 5ee5a41..089d408 100644 --- a/flake.nix +++ b/flake.nix @@ -34,506 +34,537 @@ }; }; nixos-hardware.url = "github:NixOS/nixos-hardware"; - pre-commit-hooks = { - url = "github:cachix/pre-commit-hooks.nix"; - inputs = { - nixpkgs.follows = "nixpkgs"; - }; - }; + + systems.url = "github:nix-systems/default"; + flake-parts.url = "github:hercules-ci/flake-parts"; + git-hooks-nix.url = "github:cachix/git-hooks.nix"; + # agenix-shell.url = "github:aciceri/agenix-shell"; # TODO + # agenix-rekey.url = "github:oddlama/agenix-rekey"; # TODO + # emanote.url = "github:srid/emanote"; }; - outputs = - { self - , nixpkgs - , nixpkgs-u - , home-manager - , home-manager-u - , agenix - , deploy-rs - , flake-utils - , nixos-generators - , nixos-hardware - , nix-rice - , pre-commit-hooks - , ... - }: - let - config = { - allowUnfree = true; - extraOptions = "experimental-features = nix-command flakes"; - permittedInsecurePackages = [ - "electron-27.3.11" # LogSeq - ]; - }; - - overlays = [ - # Combine stable and unstable packages - (self: _: { - stable_pkgs = import nixpkgs { - inherit config overlays; - inherit (self) system; - }; - unstable_pkgs = import nixpkgs-u { - inherit config overlays; - inherit (self) system; - }; - }) - - # Nix rice - nix-rice.overlays.default - (import ./rice.nix) - - # Flakes packages - (self: super: { - clipedit = self.callPackage ./custom/clipedit { }; - wl-clipedit = self.callPackage ./custom/wl-clipedit { }; - update-background = self.callPackage ./custom/update-background { - backgrounds_directory = "$HOME/Immagini/Sfondi/1080+/1440+"; - }; - lockscreen = self.callPackage ./custom/lockscreen { - palette = self.rice.colorPalette; - font = self.rice.font.normal; - }; - way-lockscreen = self.callPackage ./custom/way-lockscreen { - palette = self.rice.colorPalette; - font = self.rice.font.normal; - }; - sddm-theme-clairvoyance = self.callPackage ./custom/sddm-theme-clairvoyance { - wallpaper = ./wallpapers/background.jpg; - }; - keyboard-switch = self.callPackage ./custom/keyboard-switch { }; - sddm-sugar-dark = self.callPackage ./custom/sddm-sugar-dark { }; - google-chrome = super.google-chrome.override { - commandLineArgs = [ - "--password-store=gnome" - "--force-dark-mode" - ]; - }; - logseq = super.logseq.override { electron = super.electron_27; }; - }) - ]; - - basic = - with flake-utils.lib; - eachDefaultSystem ( - system: - let - pkgs = import nixpkgs { inherit system config overlays; }; - in - { - checks = { - pre-commit-check = pre-commit-hooks.lib.${system}.run { - src = ./.; - hooks = { - deadnix.enable = true; - nixpkgs-fmt.enable = true; - statix.enable = true; - }; - }; - }; - - devShells.default = pkgs.mkShell { - buildInputs = [ - # deploy-rs.packages.${system}.deploy-rs - pkgs.deploy-rs - ]; - shellHook = '' - ${self.checks.${system}.pre-commit-check.shellHook} - ''; - LOCAL_KEY = "/etc/nix/key"; - }; - - formatter = pkgs.nixpkgs-fmt; - } - ); - - nix_configuration = { - nixpkgs = { - inherit overlays config; - }; - nix = { - inherit (config) extraOptions; - registry = { - nixpkgs = { - from = { - id = "nixpkgs"; - type = "indirect"; - }; - to = { - owner = "nixos"; - repo = "nixpkgs"; - type = "github"; - }; - }; - stable = { - from = { - id = "stable"; - type = "indirect"; - }; - flake = nixpkgs; - }; - unstable = { - from = { - id = "unstable"; - type = "indirect"; - }; - flake = nixpkgs-u; - }; - }; - }; - }; - - # Home manager configuration - homeManagerModules = [ - home-manager.nixosModules.default - { - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - }; - } - ]; - - homeManagerUModules = [ - home-manager-u.nixosModules.default - { home-manager = { useGlobalPkgs = true; useUserPackages = true; }; } - ]; - - commonModules = [ - # Nix configuration - nix_configuration - - # S3 cache read - ./modules/nixos/s3_cache_read.nix - - # Agenix configuration - agenix.nixosModules.default - { - age.secrets = { - # oauth_proxy_client_credentials.file = ./secrets/oauth_proxy_client_credentials.age; - # spotify_password = { file = ./secrets/spotify_password.age; owner = "bertof"; }; - wg_psk = { - file = ./secrets/wg_psk.age; - }; - baldur_wg_priv = { - file = ./secrets/baldur_wg_priv.age; - }; - oppo_wg_priv = { - file = ./secrets/oppo_wg_priv.age; - }; - }; - } - - ./modules/nixos/users/bertof.nix - - # Some basic defaults - ./modules/nixos/basics - ]; - - installerModules = commonModules ++ [ ./modules/nixos/installer.nix ]; - - thorConfig = { - nixosConfigurations = { - thor = nixpkgs-u.lib.nixosSystem { - system = "x86_64-linux"; - modules = - commonModules - ++ [ - ./instances/thor/hardware-configuration.nix - nixos-hardware.nixosModules.common-cpu-amd - nixos-hardware.nixosModules.common-pc-ssd - ./instances/thor/configuration.nix - - # S3 cache write - ./modules/nixos/s3_cache_write.nix - - ./modules/nixos/pro_audio.nix - ./modules/nixos/kdeconnect.nix - ./modules/nixos/steam.nix - - ./modules/nixos/plymouth.nix - ./modules/nixos/hyprland.nix - { - home-manager.users.bertof.imports = [ - ./modules/hm/hyprland.nix - ./modules/hm/swayidle.nix - ]; - } - - ./modules/nixos/musa.nix - ] - ++ homeManagerUModules - ++ [{ home-manager.users.bertof = import ./instances/thor/hm.nix; }]; - }; - }; - }; - - odinConfig = { - nixosConfigurations = - let - odinCommonModules = [ - nixos-hardware.nixosModules.common-cpu-intel - nixos-hardware.nixosModules.common-pc-laptop - nixos-hardware.nixosModules.common-pc-laptop-ssd - ./instances/odin/hardware-configuration.nix - ./instances/odin/common_configuration.nix - - # S3 cache write - ./modules/nixos/s3_cache_write.nix - - # ./modules/nixos/pro_audio.nix - ./modules/nixos/kdeconnect.nix - ./modules/nixos/steam.nix - - ./modules/nixos/hyprland.nix - { home-manager.users.bertof.imports = [ ./modules/hm/hyprland.nix ]; } - - ./modules/nixos/musa.nix - ] ++ homeManagerUModules ++ [{ home-manager.users.bertof = import ./instances/odin/hm.nix; }]; - in - rec { - odin-nvidia = nixpkgs-u.lib.nixosSystem { - system = "x86_64-linux"; - modules = commonModules ++ odinCommonModules ++ [ ./instances/odin/configuration-nvidia.nix ]; - }; - - odin-intel = nixpkgs-u.lib.nixosSystem { - system = "x86_64-linux"; - modules = commonModules ++ odinCommonModules ++ [ ./instances/odin/configuration-intel.nix ]; - }; - - odin = odin-intel; - }; - }; - - heimdallConfig = { - nixosConfigurations = { - heimdall = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = - commonModules - ++ [ - nixos-hardware.nixosModules.common-cpu-amd - nixos-hardware.nixosModules.common-gpu-amd - nixos-hardware.nixosModules.common-pc-ssd - ./modules/nixos/server - - ./instances/heimdall/hardware-configuration.nix - ./instances/heimdall/configuration.nix - - ./modules/nixos/users/tiziano.nix - - ./modules/nixos/torrentbox.nix - ./modules/nixos/minio.nix - ./modules/nixos/rclone.nix - ./modules/nixos/nextcloud.nix - # ./modules/nixos/ntfy.nix - # S3 cache read - ./modules/nixos/s3_cache_read.nix - ] - ++ homeManagerModules - ++ [{ home-manager.users.bertof = import ./instances/heimdall/hm.nix; }]; - }; - }; - }; - - freyaConfig = { - nixosConfigurations = { - freya = nixpkgs.lib.nixosSystem { - system = "aarch64-linux"; - modules = - commonModules - ++ [ - nixos-hardware.nixosModules.raspberry-pi-4 - ( - { lib, ... }: - { - boot.supportedFilesystems = lib.mkForce [ - "btrfs" - "reiserfs" - "vfat" - "f2fs" - "xfs" - "ntfs" - "cifs" - ]; - } - ) - ./modules/nixos/server - - ./instances/freya/hardware-configuration.nix - ./instances/freya/configuration.nix - - ./modules/nixos/users/tiziano.nix - - ./modules/nixos/torrentbox.nix - ./modules/nixos/minio.nix - # ./modules/nixos/nextcloud.nix - ./modules/nixos/ntfy.nix - # S3 cache read - ./modules/nixos/s3_cache_read.nix - ] - ++ homeManagerModules - ++ [{ home-manager.users.bertof = import ./instances/freya/hm.nix; }]; - }; - }; - }; - - baldurConfig = { - nixosConfigurations = { - baldur = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = commonModules ++ [ - ./modules/nixos/server - ./instances/baldur/hardware-configuration.nix - ./instances/baldur/configuration.nix - # ./modules/nixos/digitalocean.nix - - ./modules/nixos/users/tiziano.nix - # S3 cache read - ./modules/nixos/s3_cache_read.nix - ] - # ++ homeManagerModules ++ [{ - # home-manager.users.bertof = import ./instances/baldur/hm.nix; - # home-manager.users.tiziano = import ./instances/baldur/hm_tiziano.nix; - # }] - ; - }; - }; - }; - - lokiConfig = { - nixosConfigurations = { - loki = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = - commonModules - ++ [ - ./modules/nixos/server - - nixos-hardware.nixosModules.common-cpu-intel - nixos-hardware.nixosModules.common-pc-ssd - ./instances/loki/hardware-configuration.nix - ./instances/loki/configuration.nix - - ./modules/nixos/users/tiziano.nix - # S3 cache read - ./modules/nixos/s3_cache_read.nix - ] - ++ homeManagerModules - ++ [ - { - home-manager.users.bertof = import ./instances/loki/hm.nix; - home-manager.users.tiziano = import ./instances/loki/hm_tiziano.nix; - } - ]; - }; - }; - }; - - deployments = { - # Deploy-rs checks - checks = builtins.mapAttrs (_system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib; - - # Map nodes to Deploy-rs deployments - deploy.nodes = { - baldur = { - hostname = "baldur.bertof.net"; - profiles.system = { - user = "root"; - path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.baldur; - }; - }; - freya = { - hostname = "freya.tsn"; - profiles.system = { - user = "root"; - path = deploy-rs.lib.aarch64-linux.activate.nixos self.nixosConfigurations.freya; - }; - }; - heimdall = { - hostname = "heimdall.tsn"; - profiles.system = { - user = "root"; - path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.heimdall; - }; - }; - loki = { - hostname = "loki.tsn"; - profiles.system = { - user = "root"; - path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.loki; - }; - }; - odin = { - hostname = "odin.tsn"; - profiles.system = { - user = "root"; - path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.odin; - }; - }; - thor = { - hostname = "thor.tsn"; - profiles.system = { - user = "root"; - path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.thor; - }; - }; - }; - }; - - images = - with flake-utils.lib; - eachSystem - [ - system.x86_64-linux - system.aarch64-linux - ] - (system: { - packages = { - # Installer ISO - install-iso = nixos-generators.nixosGenerate { - inherit system; - modules = installerModules; - format = "install-iso"; - }; - # RAW base image - raw-base-image = nixos-generators.nixosGenerate { - system = flake-utils.lib.system.x86_64-linux; - modules = installerModules; - format = "raw-efi"; - }; - # VMDK base image - vmdk-base-image = nixos-generators.nixosGenerate { - system = flake-utils.lib.system.x86_64-linux; - modules = installerModules; - format = "vmware"; - }; - # Aarch64 base image - aarch64-base-image = nixos-generators.nixosGenerate { - system = flake-utils.lib.system.aarch64-linux; - modules = installerModules; - format = "sd-aarch64"; - }; - # Installer DigitalOcean - do-image = nixos-generators.nixosGenerate { - inherit system; - modules = installerModules; - format = "do"; - }; - }; - }); - - in - builtins.foldl' nixpkgs.lib.recursiveUpdate { } [ - basic - thorConfig - odinConfig - freyaConfig - baldurConfig - heimdallConfig - lokiConfig - deployments - images + outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } { + systems = import inputs.systems; + imports = [ + inputs.git-hooks-nix.flakeModule ]; + perSystem = { config, pkgs, system, ... }: { + _module.args.pkgs = import inputs.nixpkgs { + inherit system; + config.allowUnfree = true; + }; + + pre-commit.settings.hooks = { + deadnix.enable = true; + nixpkgs-fmt.enable = true; + statix.enable = true; + }; + + devShells.default = pkgs.mkShell { + shellHook = '' + ${config.pre-commit.installationScript} + ''; + }; + + formatter = pkgs.nixpkgs-fmt; + }; + + flake = { }; + }; } + +# outputs = +# { self +# , nixpkgs +# , nixpkgs-u +# , home-manager +# , home-manager-u +# , agenix +# , deploy-rs +# , flake-utils +# , nixos-generators +# , nixos-hardware +# , nix-rice +# , pre-commit-hooks +# , ... +# }: +# let +# config = { +# allowUnfree = true; +# extraOptions = "experimental-features = nix-command flakes"; +# permittedInsecurePackages = [ +# "electron-27.3.11" # LogSeq +# ]; +# }; +# +# overlays = [ +# # Combine stable and unstable packages +# (self: _: { +# stable_pkgs = import nixpkgs { +# inherit config overlays; +# inherit (self) system; +# }; +# unstable_pkgs = import nixpkgs-u { +# inherit config overlays; +# inherit (self) system; +# }; +# }) +# +# # Nix rice +# nix-rice.overlays.default +# (import ./rice.nix) +# +# # Flakes packages +# (self: super: { +# clipedit = self.callPackage ./custom/clipedit { }; +# wl-clipedit = self.callPackage ./custom/wl-clipedit { }; +# update-background = self.callPackage ./custom/update-background { +# backgrounds_directory = "$HOME/Immagini/Sfondi/1080+/1440+"; +# }; +# lockscreen = self.callPackage ./custom/lockscreen { +# palette = self.rice.colorPalette; +# font = self.rice.font.normal; +# }; +# way-lockscreen = self.callPackage ./custom/way-lockscreen { +# palette = self.rice.colorPalette; +# font = self.rice.font.normal; +# }; +# sddm-theme-clairvoyance = self.callPackage ./custom/sddm-theme-clairvoyance { +# wallpaper = ./wallpapers/background.jpg; +# }; +# keyboard-switch = self.callPackage ./custom/keyboard-switch { }; +# sddm-sugar-dark = self.callPackage ./custom/sddm-sugar-dark { }; +# google-chrome = super.google-chrome.override { +# commandLineArgs = [ +# "--password-store=gnome" +# "--force-dark-mode" +# ]; +# }; +# logseq = super.logseq.override { electron = super.electron_27; }; +# }) +# ]; +# +# basic = +# with flake-utils.lib; +# eachDefaultSystem ( +# system: +# let +# pkgs = import nixpkgs { inherit system config overlays; }; +# in +# { +# checks = { +# pre-commit-check = pre-commit-hooks.lib.${system}.run { +# src = ./.; +# hooks = { +# deadnix.enable = true; +# nixpkgs-fmt.enable = true; +# statix.enable = true; +# }; +# }; +# }; +# +# devShells.default = pkgs.mkShell { +# buildInputs = [ +# # deploy-rs.packages.${system}.deploy-rs +# pkgs.deploy-rs +# ]; +# shellHook = '' +# ${self.checks.${system}.pre-commit-check.shellHook} +# ''; +# LOCAL_KEY = "/etc/nix/key"; +# }; +# +# formatter = pkgs.nixpkgs-fmt; +# } +# ); +# +# nix_configuration = { +# nixpkgs = { +# inherit overlays config; +# }; +# nix = { +# inherit (config) extraOptions; +# registry = { +# nixpkgs = { +# from = { +# id = "nixpkgs"; +# type = "indirect"; +# }; +# to = { +# owner = "nixos"; +# repo = "nixpkgs"; +# type = "github"; +# }; +# }; +# stable = { +# from = { +# id = "stable"; +# type = "indirect"; +# }; +# flake = nixpkgs; +# }; +# unstable = { +# from = { +# id = "unstable"; +# type = "indirect"; +# }; +# flake = nixpkgs-u; +# }; +# }; +# }; +# }; +# +# # Home manager configuration +# homeManagerModules = [ +# home-manager.nixosModules.default +# { +# home-manager = { +# useGlobalPkgs = true; +# useUserPackages = true; +# }; +# } +# ]; +# +# homeManagerUModules = [ +# home-manager-u.nixosModules.default +# { home-manager = { useGlobalPkgs = true; useUserPackages = true; }; } +# ]; +# +# commonModules = [ +# # Nix configuration +# nix_configuration +# +# # S3 cache read +# ./modules/nixos/s3_cache_read.nix +# +# # Agenix configuration +# agenix.nixosModules.default +# { +# age.secrets = { +# # oauth_proxy_client_credentials.file = ./secrets/oauth_proxy_client_credentials.age; +# # spotify_password = { file = ./secrets/spotify_password.age; owner = "bertof"; }; +# wg_psk = { +# file = ./secrets/wg_psk.age; +# }; +# baldur_wg_priv = { +# file = ./secrets/baldur_wg_priv.age; +# }; +# oppo_wg_priv = { +# file = ./secrets/oppo_wg_priv.age; +# }; +# }; +# } +# +# ./modules/nixos/users/bertof.nix +# +# # Some basic defaults +# ./modules/nixos/basics +# ]; +# +# installerModules = commonModules ++ [ ./modules/nixos/installer.nix ]; +# +# thorConfig = { +# nixosConfigurations = { +# thor = nixpkgs-u.lib.nixosSystem { +# system = "x86_64-linux"; +# modules = +# commonModules +# ++ [ +# ./instances/thor/hardware-configuration.nix +# nixos-hardware.nixosModules.common-cpu-amd +# nixos-hardware.nixosModules.common-pc-ssd +# ./instances/thor/configuration.nix +# +# # S3 cache write +# ./modules/nixos/s3_cache_write.nix +# +# ./modules/nixos/pro_audio.nix +# ./modules/nixos/kdeconnect.nix +# ./modules/nixos/steam.nix +# +# ./modules/nixos/plymouth.nix +# ./modules/nixos/hyprland.nix +# { +# home-manager.users.bertof.imports = [ +# ./modules/hm/hyprland.nix +# ./modules/hm/swayidle.nix +# ]; +# } +# +# ./modules/nixos/musa.nix +# ] +# ++ homeManagerUModules +# ++ [{ home-manager.users.bertof = import ./instances/thor/hm.nix; }]; +# }; +# }; +# }; +# +# odinConfig = { +# nixosConfigurations = +# let +# odinCommonModules = [ +# nixos-hardware.nixosModules.common-cpu-intel +# nixos-hardware.nixosModules.common-pc-laptop +# nixos-hardware.nixosModules.common-pc-laptop-ssd +# ./instances/odin/hardware-configuration.nix +# ./instances/odin/common_configuration.nix +# +# # S3 cache write +# ./modules/nixos/s3_cache_write.nix +# +# # ./modules/nixos/pro_audio.nix +# ./modules/nixos/kdeconnect.nix +# ./modules/nixos/steam.nix +# +# ./modules/nixos/hyprland.nix +# { home-manager.users.bertof.imports = [ ./modules/hm/hyprland.nix ]; } +# +# ./modules/nixos/musa.nix +# ] ++ homeManagerUModules ++ [{ home-manager.users.bertof = import ./instances/odin/hm.nix; }]; +# in +# rec { +# odin-nvidia = nixpkgs-u.lib.nixosSystem { +# system = "x86_64-linux"; +# modules = commonModules ++ odinCommonModules ++ [ ./instances/odin/configuration-nvidia.nix ]; +# }; +# +# odin-intel = nixpkgs-u.lib.nixosSystem { +# system = "x86_64-linux"; +# modules = commonModules ++ odinCommonModules ++ [ ./instances/odin/configuration-intel.nix ]; +# }; +# +# odin = odin-intel; +# }; +# }; +# +# heimdallConfig = { +# nixosConfigurations = { +# heimdall = nixpkgs.lib.nixosSystem { +# system = "x86_64-linux"; +# modules = +# commonModules +# ++ [ +# nixos-hardware.nixosModules.common-cpu-amd +# nixos-hardware.nixosModules.common-gpu-amd +# nixos-hardware.nixosModules.common-pc-ssd +# ./modules/nixos/server +# +# ./instances/heimdall/hardware-configuration.nix +# ./instances/heimdall/configuration.nix +# +# ./modules/nixos/users/tiziano.nix +# +# ./modules/nixos/torrentbox.nix +# ./modules/nixos/minio.nix +# ./modules/nixos/rclone.nix +# ./modules/nixos/nextcloud.nix +# # ./modules/nixos/ntfy.nix +# # S3 cache read +# ./modules/nixos/s3_cache_read.nix +# ] +# ++ homeManagerModules +# ++ [{ home-manager.users.bertof = import ./instances/heimdall/hm.nix; }]; +# }; +# }; +# }; +# +# freyaConfig = { +# nixosConfigurations = { +# freya = nixpkgs.lib.nixosSystem { +# system = "aarch64-linux"; +# modules = +# commonModules +# ++ [ +# nixos-hardware.nixosModules.raspberry-pi-4 +# ( +# { lib, ... }: +# { +# boot.supportedFilesystems = lib.mkForce [ +# "btrfs" +# "reiserfs" +# "vfat" +# "f2fs" +# "xfs" +# "ntfs" +# "cifs" +# ]; +# } +# ) +# ./modules/nixos/server +# +# ./instances/freya/hardware-configuration.nix +# ./instances/freya/configuration.nix +# +# ./modules/nixos/users/tiziano.nix +# +# ./modules/nixos/torrentbox.nix +# ./modules/nixos/minio.nix +# # ./modules/nixos/nextcloud.nix +# ./modules/nixos/ntfy.nix +# # S3 cache read +# ./modules/nixos/s3_cache_read.nix +# ] +# ++ homeManagerModules +# ++ [{ home-manager.users.bertof = import ./instances/freya/hm.nix; }]; +# }; +# }; +# }; +# +# baldurConfig = { +# nixosConfigurations = { +# baldur = nixpkgs.lib.nixosSystem { +# system = "x86_64-linux"; +# modules = commonModules ++ [ +# ./modules/nixos/server +# ./instances/baldur/hardware-configuration.nix +# ./instances/baldur/configuration.nix +# # ./modules/nixos/digitalocean.nix +# +# ./modules/nixos/users/tiziano.nix +# # S3 cache read +# ./modules/nixos/s3_cache_read.nix +# ] +# # ++ homeManagerModules ++ [{ +# # home-manager.users.bertof = import ./instances/baldur/hm.nix; +# # home-manager.users.tiziano = import ./instances/baldur/hm_tiziano.nix; +# # }] +# ; +# }; +# }; +# }; +# +# lokiConfig = { +# nixosConfigurations = { +# loki = nixpkgs.lib.nixosSystem { +# system = "x86_64-linux"; +# modules = +# commonModules +# ++ [ +# ./modules/nixos/server +# +# nixos-hardware.nixosModules.common-cpu-intel +# nixos-hardware.nixosModules.common-pc-ssd +# ./instances/loki/hardware-configuration.nix +# ./instances/loki/configuration.nix +# +# ./modules/nixos/users/tiziano.nix +# # S3 cache read +# ./modules/nixos/s3_cache_read.nix +# ] +# ++ homeManagerModules +# ++ [ +# { +# home-manager.users.bertof = import ./instances/loki/hm.nix; +# home-manager.users.tiziano = import ./instances/loki/hm_tiziano.nix; +# } +# ]; +# }; +# }; +# }; +# +# deployments = { +# # Deploy-rs checks +# checks = builtins.mapAttrs (_system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib; +# +# # Map nodes to Deploy-rs deployments +# deploy.nodes = { +# baldur = { +# hostname = "baldur.bertof.net"; +# profiles.system = { +# user = "root"; +# path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.baldur; +# }; +# }; +# freya = { +# hostname = "freya.tsn"; +# profiles.system = { +# user = "root"; +# path = deploy-rs.lib.aarch64-linux.activate.nixos self.nixosConfigurations.freya; +# }; +# }; +# heimdall = { +# hostname = "heimdall.tsn"; +# profiles.system = { +# user = "root"; +# path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.heimdall; +# }; +# }; +# loki = { +# hostname = "loki.tsn"; +# profiles.system = { +# user = "root"; +# path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.loki; +# }; +# }; +# odin = { +# hostname = "odin.tsn"; +# profiles.system = { +# user = "root"; +# path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.odin; +# }; +# }; +# thor = { +# hostname = "thor.tsn"; +# profiles.system = { +# user = "root"; +# path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.thor; +# }; +# }; +# }; +# }; +# +# images = +# with flake-utils.lib; +# eachSystem +# [ +# system.x86_64-linux +# system.aarch64-linux +# ] +# (system: { +# packages = { +# # Installer ISO +# install-iso = nixos-generators.nixosGenerate { +# inherit system; +# modules = installerModules; +# format = "install-iso"; +# }; +# # RAW base image +# raw-base-image = nixos-generators.nixosGenerate { +# system = flake-utils.lib.system.x86_64-linux; +# modules = installerModules; +# format = "raw-efi"; +# }; +# # VMDK base image +# vmdk-base-image = nixos-generators.nixosGenerate { +# system = flake-utils.lib.system.x86_64-linux; +# modules = installerModules; +# format = "vmware"; +# }; +# # Aarch64 base image +# aarch64-base-image = nixos-generators.nixosGenerate { +# system = flake-utils.lib.system.aarch64-linux; +# modules = installerModules; +# format = "sd-aarch64"; +# }; +# # Installer DigitalOcean +# do-image = nixos-generators.nixosGenerate { +# inherit system; +# modules = installerModules; +# format = "do"; +# }; +# }; +# }); +# +# in +# builtins.foldl' nixpkgs.lib.recursiveUpdate { } [ +# basic +# thorConfig +# odinConfig +# freyaConfig +# baldurConfig +# heimdallConfig +# lokiConfig +# deployments +# images +# ]; +# }