From 0ec27dd717b0b961f7dc49fee981d094067c9f34 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Tue, 18 Apr 2023 13:03:19 +0200 Subject: [PATCH] Restructure flake --- common.nix | 11 +++--- flake.lock | 24 ++++++------- flake.nix | 58 +++++++++++++++++--------------- modules/common/linux/default.nix | 16 +++++---- 4 files changed, 58 insertions(+), 51 deletions(-) diff --git a/common.nix b/common.nix index e9f1d86..c24a898 100644 --- a/common.nix +++ b/common.nix @@ -16,10 +16,11 @@ with lib; { ./modules/common/linux ./modules/my-tinc ]; - # swaync disable notifications on screencast - config.xdg.portal.wlr.settings.screencast = { - exec_before = ''which swaync-client && swaync-client --inhibitor-add "xdg-desktop-portal-wlr" || true''; - exec_after = ''which swaync-client && swaync-client --inhibitor-remove "xdg-desktop-portal-wlr" || true''; - }; + ## Packages + # Nix options + # Always have flakes enabled! + nix.extraOptions = '' + experimental-features = nix-command flakes repl-flake + ''; } diff --git a/flake.lock b/flake.lock index 7327b15..916c54f 100644 --- a/flake.lock +++ b/flake.lock @@ -351,11 +351,11 @@ "rust-overlay": "rust-overlay_2" }, "locked": { - "lastModified": 1677216540, - "narHash": "sha256-t7vsvKalN24LUrIABHk3OlzpXhrTfS40AdP6whv3C9I=", + "lastModified": 1679451428, + "narHash": "sha256-Xk3WBlejWUpnuOnMZzTH7mV/bTRxKIrln871ba3uQjI=", "owner": "tpwrules", "repo": "nixos-apple-silicon", - "rev": "e79177006306ae592bc865b03667af4229620461", + "rev": "696d7b4ac7ca05684a3cceedd44acfd0d1c5f1e3", "type": "github" }, "original": { @@ -398,15 +398,15 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1681215634, - "narHash": "sha256-dI0SsSWb7ksK3OtTCf61vdlBhok838aIpwQ2EUM+jhY=", - "owner": "nixos", + "lastModified": 1681740123, + "narHash": "sha256-RrcHEqm+f04nFpQQSnsGsUhJb2mNuqfdcGWL2DREEaY=", + "owner": "natsukagami", "repo": "nixpkgs", - "rev": "5a156c2e89c1eca09b40bcdcee86760e0e4d79a9", + "rev": "55325c13e8f5c06a57a210b30a19b2fbebe185f1", "type": "github" }, "original": { - "owner": "nixos", + "owner": "natsukagami", "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" @@ -595,11 +595,11 @@ "flake-utils": "flake-utils_4" }, "locked": { - "lastModified": 1669915544, - "narHash": "sha256-wByoZ+HWXo7L9QyUefMhe26IUUeFGtffG6v/AL31neo=", + "lastModified": 1681814227, + "narHash": "sha256-YQET7Vnnc6f8k2M2YhKbflFSPFfdgpVCn7xFYiMLPTE=", "ref": "refs/heads/master", - "rev": "9142ca82ec1e9a6e1314d2727cdc15db30c94c14", - "revCount": 4, + "rev": "a810d3209929ec0a44efdc2171b92f3723bb8a6a", + "revCount": 5, "type": "git", "url": "ssh://git@github.com/natsukagami/nix-deploy-secrets" }, diff --git a/flake.nix b/flake.nix index 3e6f551..823522b 100644 --- a/flake.nix +++ b/flake.nix @@ -3,7 +3,7 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11"; - nixpkgs-unstable.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + nixpkgs-unstable.url = "github:natsukagami/nixpkgs/nixpkgs-unstable"; # nixpkgs-unstable.follows = "nixos-m1/nixpkgs"; darwin.url = "github:lnl7/nix-darwin/master"; darwin.inputs.nixpkgs.follows = "nixpkgs-unstable"; @@ -52,11 +52,15 @@ outputs = { self, darwin, nixpkgs, nixpkgs-unstable, home-manager, deploy-rs, sops-nix, nur, ... }@inputs: let overlays = import ./overlay.nix inputs; + lib = nixpkgs.lib; - pkgs' = system: import nixpkgs { inherit system overlays; config.allowUnfree = true; }; - pkgs-unstable = system: import nixpkgs-unstable { inherit system overlays; config.allowUnfree = true; }; + applyOverlays = { ... }: { + nixpkgs.overlays = lib.mkBefore overlays; + }; - nixpkgsAsRegistry_ = stable: { ... }: { + nixpkgsAsRegistry_ = stable: { lib, ... }: { + imports = [ applyOverlays ]; + nix.registry.current-system.flake = self; nix.registry.nixpkgs.flake = stable; nix.registry.nixpkgs-unstable.flake = nixpkgs-unstable; nix.nixPath = [ @@ -64,10 +68,6 @@ "nixpkgs-unstable=${nixpkgs-unstable}" "/nix/var/nix/profiles/per-user/root/channels" ]; - }; - nixpkgsAsRegistry = nixpkgsAsRegistry_ nixpkgs; - - haskellDotNix = { ... }: { # Binary Cache for Haskell.nix nix.settings.trusted-public-keys = [ "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" @@ -76,6 +76,22 @@ "https://cache.iog.io" ]; }; + nixpkgsAsRegistry = nixpkgsAsRegistry_ nixpkgs; + + # Common Nix modules + common-nix = stable: { ... }: { + imports = [ + (nixpkgsAsRegistry_ stable) + ./common.nix + sops-nix.nixosModules.sops + ]; + }; + common-nixos = stable: { ... }: { + imports = [ + (common-nix stable) + inputs.secrets.nixosModules.common + ]; + }; enableOsuStable = { lib, ... }: { imports = [ inputs.nix-gaming.nixosModules.pipewireLowLatency ]; @@ -98,15 +114,14 @@ }; in { + overlays.default = lib.composeManyExtensions overlays; + # MacBook configuration: nix-darwin + home-manager darwinConfigurations."nki-macbook" = darwin.lib.darwinSystem rec { system = "aarch64-darwin"; - pkgs = pkgs-unstable system; modules = [ + (common-nix nixpkgs-unstable) ./darwin/configuration.nix - # Set nix path - haskellDotNix - (nixpkgsAsRegistry_ nixpkgs-unstable) inputs.home-manager-unstable.darwinModules.home-manager { home-manager.useGlobalPkgs = true; @@ -119,12 +134,9 @@ # Home configuration nixosConfigurations."nki-home" = nixpkgs.lib.nixosSystem rec { system = "x86_64-linux"; - pkgs = pkgs' system; modules = [ - ./common.nix - sops-nix.nixosModules.sops + (common-nixos nixpkgs) ./nki-home/configuration.nix - nixpkgsAsRegistry enableOsuStable home-manager.nixosModules.home-manager { @@ -137,17 +149,14 @@ ]; }; } - inputs.secrets.nixosModules.x86_64-linux.common ]; }; # x1c1 configuration nixosConfigurations."nki-x1c1" = nixpkgs.lib.nixosSystem rec { - pkgs = pkgs' system; system = "x86_64-linux"; modules = [ - sops-nix.nixosModules.sops + (common-nixos nixpkgs) ./nki-x1c1/configuration.nix - nixpkgsAsRegistry home-manager.nixosModules.home-manager { home-manager.useGlobalPkgs = true; @@ -158,32 +167,27 @@ }; # macbook nixos nixosConfigurations."kagami-air-m1" = nixpkgs-unstable.lib.nixosSystem rec { - pkgs = pkgs-unstable system; system = "aarch64-linux"; modules = [ - ./common.nix - sops-nix.nixosModules.sops + (common-nixos nixpkgs) inputs.nixos-m1.nixosModules.apple-silicon-support ./kagami-air-m1/configuration.nix - nixpkgsAsRegistry inputs.home-manager-unstable.nixosModules.home-manager { home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; home-manager.users.nki = import ./home/macbook-nixos.nix; } - inputs.secrets.nixosModules.${system}.common ]; }; # DigitalOcean node nixosConfigurations."nki-personal-do" = nixpkgs.lib.nixosSystem rec { - pkgs = pkgs' system; system = "x86_64-linux"; modules = [ + (common-nixos nixpkgs) ./modules/my-tinc inputs.youmubot.nixosModule.x86_64-linux - sops-nix.nixosModules.sops ./nki-personal-do/configuration.nix inputs.secrets.nixosModules.x86_64-linux.nki-personal-do ]; diff --git a/modules/common/linux/default.nix b/modules/common/linux/default.nix index 787b09e..627a18f 100644 --- a/modules/common/linux/default.nix +++ b/modules/common/linux/default.nix @@ -19,10 +19,18 @@ let networkConfig.DHCP = "yes"; }; }; + + wlr = { ... }: mkIf config.common.linux.enable { + # swaync disable notifications on screencast + xdg.portal.wlr.settings.screencast = { + exec_before = ''which swaync-client && swaync-client --inhibitor-add "xdg-desktop-portal-wlr" || true''; + exec_after = ''which swaync-client && swaync-client --inhibitor-remove "xdg-desktop-portal-wlr" || true''; + }; + }; }; in { - imports = with modules; [ adb ios ]; + imports = with modules; [ adb ios wlr ]; options.common.linux = { enable = mkOption { @@ -165,12 +173,6 @@ in ]; }; - ## Packages - # Nix options - # Always have flakes enabled! - nix.extraOptions = '' - experimental-features = nix-command flakes - ''; # Default packages environment.systemPackages = with pkgs; [ kakoune # An editor