From c9ee01f65e4ba81425620c37d4159b9c8d58c8ba Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 4 Jul 2022 15:41:04 -0400 Subject: [PATCH] Modernizing overlay --- darwin/brew.nix | 17 +-------------- darwin/configuration.nix | 5 +---- flake.nix | 46 +++++++++++++++++++++++----------------- overlay.nix | 26 +++++++++++------------ 4 files changed, 41 insertions(+), 53 deletions(-) diff --git a/darwin/brew.nix b/darwin/brew.nix index ed74b78..9260844 100644 --- a/darwin/brew.nix +++ b/darwin/brew.nix @@ -16,27 +16,12 @@ with lib; ]; homebrew.brews = [ - # Base libraries - "coreutils" - - # Compilers and Language Interpreters - "elm" - "llvm" - "luajit-openresty" - "node" - "perl" - "ruby@2.7" - # CLI tools "pinentry-mac" # UI for Pin Entry on gpg Mac # U2F "pam-u2f" - ] ++ (optionals (pkgs.system == "aarch64-darwin") [ - # Because python on Nix is a bit abababa - "python@3.9" - "scipy" - ]); + ]; homebrew.casks = [ "anki" diff --git a/darwin/configuration.nix b/darwin/configuration.nix index 54c9ab9..4de1593 100644 --- a/darwin/configuration.nix +++ b/darwin/configuration.nix @@ -16,7 +16,7 @@ # Auto upgrade nix package and the daemon service. # services.nix-daemon.enable = true; - nix.package = pkgs.nixUnstable; + nix.package = pkgs.nixFlakes; # Create /etc/bashrc that loads the nix-darwin environment. programs.zsh.enable = true; # default shell on catalina @@ -25,9 +25,6 @@ ## Networking related settings networking.hostName = "nki-macbook"; - ## Programs - nixpkgs.config.allowUnfree = true; - environment.variables = { EDITOR = ""; # don't set it by default diff --git a/flake.nix b/flake.nix index 1cbe510..2fb8bba 100644 --- a/flake.nix +++ b/flake.nix @@ -29,10 +29,13 @@ outputs = { self, darwin, nixpkgs, nixpkgs-unstable, home-manager, deploy-rs, sops-nix, nur, ... }@inputs: let - overlayForSystem = import ./overlay.nix inputs; + overlays = import ./overlay.nix inputs; - nixpkgsAsRegistry = { ... }: { - nix.registry.nixpkgs.flake = nixpkgs; + pkgs = system: import nixpkgs { inherit system overlays; }; + pkgs-unstable = system: import nixpkgs-unstable { inherit system overlays; }; + + nixpkgsAsRegistry_ = stable: { ... }: { + nix.registry.nixpkgs.flake = stable; nix.registry.nixpkgs-unstable.flake = nixpkgs-unstable; nix.nixPath = [ "nixpkgs=${nixpkgs}" @@ -40,6 +43,17 @@ "/nix/var/nix/profiles/per-user/root/channels" ]; }; + nixpkgsAsRegistry = nixpkgsAsRegistry_ nixpkgs; + + haskellDotNix = { ... }: { + # Binary Cache for Haskell.nix + nix.binaryCachePublicKeys = [ + "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" + ]; + nix.binaryCaches = [ + "https://cache.iog.io" + ]; + }; enableOsuStable = { lib, ... }: { imports = [ inputs.nix-gaming.nixosModules.pipewireLowLatency ]; @@ -63,31 +77,26 @@ in { # MacBook configuration: nix-darwin + home-manager - darwinConfigurations."nki-macbook" = darwin.lib.darwinSystem { + darwinConfigurations."nki-macbook" = darwin.lib.darwinSystem rec { system = "aarch64-darwin"; + pkgs = pkgs-unstable system; modules = [ ./darwin/configuration.nix # Set nix path - ({ ... }: { - nix.nixPath = [ - "nixpkgs=${nixpkgs-unstable}" - "nixpkgs-unstable=${nixpkgs-unstable}" - "/nix/var/nix/profiles/per-user/root/channels" - "\$HOME/.nix-defexpr/channels" - ]; - }) + haskellDotNix + (nixpkgsAsRegistry_ nixpkgs-unstable) home-manager.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 { + nixosConfigurations."nki-home" = nixpkgs.lib.nixosSystem rec { + pkgs = pkgs system; system = "x86_64-linux"; modules = [ ./modules/my-tinc @@ -102,11 +111,11 @@ home-manager.users.nki = import ./home/kagami-pc-home.nix; } inputs.secrets.nixosModules.x86_64-linux.common - (overlayForSystem "x86_64-linux") ]; }; # x1c1 configuration - nixosConfigurations."nki-x1c1" = nixpkgs.lib.nixosSystem { + nixosConfigurations."nki-x1c1" = nixpkgs.lib.nixosSystem rec { + pkgs = pkgs system; system = "x86_64-linux"; modules = [ ./modules/my-tinc @@ -119,12 +128,12 @@ home-manager.useUserPackages = true; home-manager.users.nki = import ./home/nki-x1c1.nix; } - (overlayForSystem "x86_64-linux") ]; }; # DigitalOcean node - nixosConfigurations."nki-personal-do" = nixpkgs.lib.nixosSystem { + nixosConfigurations."nki-personal-do" = nixpkgs.lib.nixosSystem rec { + pkgs = pkgs system; system = "x86_64-linux"; modules = [ ./modules/my-tinc @@ -132,7 +141,6 @@ sops-nix.nixosModules.sops ./nki-personal-do/configuration.nix inputs.secrets.nixosModules.x86_64-linux.nki-personal-do - (overlayForSystem "x86_64-linux") ]; }; deploy.nodes."nki-personal-do" = { diff --git a/overlay.nix b/overlay.nix index 0169c56..464df46 100644 --- a/overlay.nix +++ b/overlay.nix @@ -1,28 +1,26 @@ -{ nixpkgs, nixpkgs-unstable, nur, ... }@inputs: system: +{ nixpkgs, nixpkgs-unstable, nur, ... }@inputs: 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; }; + x86 = import nixpkgs-unstable { system = prev.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}"; + rnix-lsp = inputs.rnix-lsp.defaultPackage."${prev.system}"; }; in -{ - nixpkgs.overlays = [ - (import ./overlays/openrazer) - overlay-unstable - overlay-needs-unstable - overlay-imported - nur.overlay +[ + (import ./overlays/openrazer) + overlay-unstable + overlay-needs-unstable + overlay-imported + nur.overlay - # Bug fixes - (import ./overlays/bugfixes/delta) - ]; # we assign the overlay created before to the overlays of nixpkgs. -} + # Bug fixes + (import ./overlays/bugfixes/delta) +] # we assign the overlay created before to the overlays of nixpkgs.