From d37f6808f5627300677a69975a9b09e48a0770c7 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Fri, 29 Oct 2021 13:31:16 -0400 Subject: [PATCH] Things should work for macbook too --- flake.lock | 55 ++++++++++++++++---------------- flake.nix | 73 +++++++++++++++++++------------------------ home/common.nix | 5 +-- home/fish/fish.nix | 2 +- home/macbook-home.nix | 7 ++--- overlay.nix | 19 +++++++++++ 6 files changed, 86 insertions(+), 75 deletions(-) create mode 100644 overlay.nix diff --git a/flake.lock b/flake.lock index ed5df6b..b4da1f8 100644 --- a/flake.lock +++ b/flake.lock @@ -60,20 +60,18 @@ }, "naersk": { "inputs": { - "nixpkgs": [ - "nixpkgs" - ] + "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1629707199, - "narHash": "sha256-sGxlmfp5eXL5sAMNqHSb04Zq6gPl+JeltIZ226OYN0w=", - "owner": "nmattia", + "lastModified": 1635444951, + "narHash": "sha256-1y3YkERwoYDIZjGow7HLAR8K3C/9VBPCBy8VpftMPsM=", + "owner": "nix-community", "repo": "naersk", - "rev": "df71f5e4babda41cd919a8684b72218e2e809fa9", + "rev": "0d2ce479df4633dbeb53a8ea96e5098ed37fbcc6", "type": "github" }, "original": { - "owner": "nmattia", + "owner": "nix-community", "repo": "naersk", "type": "github" } @@ -123,6 +121,20 @@ } }, "nixpkgs_3": { + "locked": { + "lastModified": 1635527206, + "narHash": "sha256-vuktnugcLNX5HFpj8nVSKgojRDYQlxtKtcYWtOveegE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "7565e8eb3278125807f7f7abafcd3232f77746d9", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_4": { "locked": { "lastModified": 1622516815, "narHash": "sha256-ZjBd81a6J3TwtlBr3rHsZspYUwT9OdhDk+a/SgSEf7I=", @@ -138,22 +150,6 @@ "type": "github" } }, - "nixpkgs_4": { - "locked": { - "lastModified": 1630481079, - "narHash": "sha256-leWXLchbAbqOlLT6tju631G40SzQWPqaAXQG3zH1Imw=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "110a2c9ebbf5d4a94486854f18a37a938cfacbbb", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-21.05", - "repo": "nixpkgs", - "type": "github" - } - }, "nixpkgs_5": { "locked": { "lastModified": 1625223284, @@ -187,8 +183,12 @@ }, "rnix-lsp": { "inputs": { - "naersk": "naersk", - "nixpkgs": "nixpkgs_4", + "naersk": [ + "naersk" + ], + "nixpkgs": [ + "nixpkgs-unstable" + ], "utils": "utils" }, "locked": { @@ -210,7 +210,8 @@ "darwin": "darwin", "home-manager-21_05": "home-manager-21_05", "home-manager-unstable": "home-manager-unstable", - "nixpkgs": "nixpkgs_3", + "naersk": "naersk", + "nixpkgs": "nixpkgs_4", "nixpkgs-unstable": "nixpkgs-unstable", "nur": "nur", "rnix-lsp": "rnix-lsp", diff --git a/flake.nix b/flake.nix index f26be2b..dfa08b3 100644 --- a/flake.nix +++ b/flake.nix @@ -13,54 +13,47 @@ # --- # Imported apps + naersk.url = "github:nix-community/naersk"; rnix-lsp.url = "github:nix-community/rnix-lsp"; + rnix-lsp.inputs.naersk.follows = "naersk"; + rnix-lsp.inputs.nixpkgs.follows = "nixpkgs-unstable"; }; - outputs = { self, darwin, nixpkgs, nixpkgs-unstable, home-manager-unstable, home-manager-21_05, sops-nix, nur, ... }@inputs : { - # MacBook configuration: nix-darwin + home-manager - darwinConfigurations."nki-macbook" = darwin.lib.darwinSystem { - system = "aarch64-darwin"; - modules = [ - ./darwin/configuration.nix + outputs = { self, darwin, nixpkgs, nixpkgs-unstable, home-manager-unstable, home-manager-21_05, sops-nix, nur, ... }@inputs: + let + overlayForSystem = import ./overlay.nix inputs; + in + { + # MacBook configuration: nix-darwin + home-manager + darwinConfigurations."nki-macbook" = darwin.lib.darwinSystem { + system = "aarch64-darwin"; + modules = [ + ./darwin/configuration.nix home-manager-unstable.darwinModules.home-manager { home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; home-manager.users.nki = import ./home/macbook-home.nix; - } - ]; - }; + } + (overlayForSystem "aarch64-darwin") + ]; + }; - # Home configuration - nixosConfigurations."nki-home" = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./modules/my-tinc - sops-nix.nixosModules.sops - ./nki-home/configuration.nix - home-manager-21_05.nixosModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.users.nki = import ./home/kagami-pc-home.nix; - } - (let - overlay-unstable = final: prev: { - unstable = import nixpkgs-unstable { config.allowUnfree = true; system = prev.system; }; - unfree = import nixpkgs { config.allowUnfree = true; system = prev.system; }; - }; - overlay-needs-unstable = final: prev: { - # override some packages that needs unstable that cannot be changed in the setup. - nix-direnv = prev.unstable.nix-direnv; - }; - overlay-imported = final: prev: { - rnix-lsp = inputs.rnix-lsp.defaultPackage."x86_64-linux"; - }; - in - { - nixpkgs.overlays = [ overlay-unstable overlay-needs-unstable overlay-imported nur.overlay ]; # we assign the overlay created before to the overlays of nixpkgs. - }) - ]; + # Home configuration + nixosConfigurations."nki-home" = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ./modules/my-tinc + sops-nix.nixosModules.sops + ./nki-home/configuration.nix + home-manager-21_05.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.nki = import ./home/kagami-pc-home.nix; + } + (overlayForSystem "x86_64-linux") + ]; + }; }; - }; } diff --git a/home/common.nix b/home/common.nix index 3091c81..8217ada 100644 --- a/home/common.nix +++ b/home/common.nix @@ -1,4 +1,4 @@ -{ config, pkgs, ... }: +{ config, pkgs, lib, ... }: { imports = [ @@ -96,7 +96,8 @@ gh = { enable = true; - gitProtocol = "ssh"; + gitProtocol = lib.mkIf (config.home.stateVersion == "21.05") "ssh"; + settings.git_protocol = lib.mkIf (config.home.stateVersion == "21.11") "ssh"; }; git = { diff --git a/home/fish/fish.nix b/home/fish/fish.nix index c13160f..837f18e 100644 --- a/home/fish/fish.nix +++ b/home/fish/fish.nix @@ -1,4 +1,4 @@ -{ config, pkgs, nixpkgs-unstable, ... }: +{ config, pkgs, ... }: { programs.fish = { diff --git a/home/macbook-home.nix b/home/macbook-home.nix index 807e0b9..4d2f78e 100644 --- a/home/macbook-home.nix +++ b/home/macbook-home.nix @@ -1,8 +1,5 @@ -{ config, pkgs, nixpkgs-unstable, ... }: +{ config, pkgs, ... }: -let - x86pkgs = import nixpkgs-unstable { system = pkgs.system; config.allowUnsupportedSystem = true; }; -in { imports = [ ./common.nix ]; @@ -16,7 +13,7 @@ in # Additional packages to be used only on this MacBook. home.packages = with pkgs; [ - x86pkgs.anki-bin + pkgs.x86.anki-bin ]; # Additional settings for programs diff --git a/overlay.nix b/overlay.nix new file mode 100644 index 0000000..690d9fc --- /dev/null +++ b/overlay.nix @@ -0,0 +1,19 @@ +{ nixpkgs, nixpkgs-unstable, nur, ... }@inputs: system: +let + overlay-unstable = final: prev: { + unstable = import nixpkgs-unstable { config.allowUnfree = true; system = prev.system; }; + unfree = import nixpkgs { config.allowUnfree = true; system = prev.system; }; + x86 = import nixpkgs-unstable { system = "${system}"; config.allowUnsupportedSystem = true; }; + }; + overlay-needs-unstable = final: prev: { + # override some packages that needs unstable that cannot be changed in the setup. + nix-direnv = prev.unstable.nix-direnv; + }; + overlay-imported = final: prev: { + rnix-lsp = inputs.rnix-lsp.defaultPackage."${system}"; + }; +in +{ + nixpkgs.overlays = [ overlay-unstable overlay-needs-unstable overlay-imported nur.overlay ]; # we assign the overlay created before to the overlays of nixpkgs. +} +