From 300d7aa00a8b3b75d35a839f167479405c48b5f5 Mon Sep 17 00:00:00 2001 From: winston Date: Fri, 10 Feb 2023 06:29:23 +0100 Subject: [PATCH] feat: use home-manager as a nix-darwin module --- darwin.nix | 2 ++ flake.lock | 35 ++++++------------ flake.nix | 81 ++++++++++++++---------------------------- home.nix | 13 +++---- justfile | 9 ++--- modules/firefox.nix | 2 +- modules/mail.nix | 12 ------- modules/neovim.nix | 2 +- modules/sketchybar.nix | 2 +- shell.nix | 2 ++ 10 files changed, 53 insertions(+), 107 deletions(-) diff --git a/darwin.nix b/darwin.nix index fc306a9..dbf6b48 100644 --- a/darwin.nix +++ b/darwin.nix @@ -12,6 +12,8 @@ }; }; + users.users.winston.home = "/Users/winston"; + # Used for backwards compatibility, please read the changelog before changing. # $ darwin-rebuild changelog system.stateVersion = 4; diff --git a/flake.lock b/flake.lock index 5e51f5e..c73ae69 100644 --- a/flake.lock +++ b/flake.lock @@ -21,20 +21,6 @@ "type": "github" } }, - "flake-utils": { - "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", - "type": "github" - }, - "original": { - "id": "flake-utils", - "type": "indirect" - } - }, "home-manager": { "inputs": { "nixpkgs": [ @@ -73,18 +59,18 @@ "type": "github" } }, - "nixpkgs-22_05": { + "nixpkgs-stable": { "locked": { - "lastModified": 1656955776, - "narHash": "sha256-1aMu67m+orlGxVwfiX3RxTEVFoq/RmKa/L5u9zU3UNQ=", + "lastModified": 1676003493, + "narHash": "sha256-D7al8mRCMBu6eOF62Nlx1jzCSU6odbBK/OJVynqnMHc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "cc16da2c92041cbe817c40f62aac87c99104e9c2", + "rev": "8866a38d4d24542f2a355b6b2c7591a4bc78b343", "type": "github" }, "original": { "owner": "NixOS", - "ref": "release-22.05", + "ref": "release-22.11", "repo": "nixpkgs", "type": "github" } @@ -140,7 +126,6 @@ "root": { "inputs": { "darwin": "darwin", - "flake-utils": "flake-utils", "home-manager": "home-manager", "nixpkgs": "nixpkgs", "nixpkgs-unstable": "nixpkgs-unstable", @@ -151,19 +136,19 @@ "sops": { "inputs": { "nixpkgs": "nixpkgs_2", - "nixpkgs-22_05": "nixpkgs-22_05" + "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1675284668, - "narHash": "sha256-wJMCAr3GV8GXVWnDTf06QdZRwe6zp8oD/X6PdIWS8/I=", + "lastModified": 1675872570, + "narHash": "sha256-RPH3CeTv7ixC2WcYiKyhmIgoH/9tur4Kr+3Vg/pleQk=", "owner": "Mic92", "repo": "sops-nix", - "rev": "9d523ff9cf0d9c3ad097443491fe7ed2187b17ed", + "rev": "8fec29b009c19538e68d5d814ec74e04f662fbd1", "type": "github" }, "original": { "owner": "Mic92", - "ref": "feat/home-manager", + "ref": "master", "repo": "sops-nix", "type": "github" } diff --git a/flake.nix b/flake.nix index a3952b3..a7f43af 100644 --- a/flake.nix +++ b/flake.nix @@ -15,13 +15,12 @@ inputs.nixpkgs.follows = "nixpkgs"; }; nur.url = "github:nix-community/NUR/master"; - sops.url = "github:Mic92/sops-nix/feat/home-manager"; + sops.url = "github:Mic92/sops-nix/master"; }; outputs = { self, darwin, - flake-utils, home-manager, nixpkgs, nixpkgs-unstable, @@ -30,72 +29,44 @@ ... }: let - overlay-unstable-x86-64 = final: prev: { + overlay-unstable = final: prev: { unstable = import nixpkgs-unstable { - system = "x86_64-linux"; + system = prev.system; config.allowUnfree = true; }; }; - overlay-unstable-aarch64 = final: prev: { - unstable = import nixpkgs-unstable { - system = "aarch64-darwin"; - config.allowUnfree = true; - }; - }; - in - rec { - # TODO: enable for NixOS - # nixosConfigurations = { - # "copium" = nixpkgs.lib.nixosSystem { - # system = "x86_64-linux"; - # modules = [ - # # make "pkgs.unstable" available - # ({ config, pkgs, ... }: { nixpkgs.overlays = [ overlay-unstable ]; }) - # ./configuration.nix - # ]; - # }; - # }; - + in { darwinConfigurations = { "sashimi-slicer" = darwin.lib.darwinSystem rec { system = "aarch64-darwin"; - # pkgs = import nixpkgs { - # inherit system; - # config.allowUnfree = true; - # }; modules = [ + home-manager.darwinModules.home-manager + ./darwin.nix - # make "pkgs.unstable" available - ({ config, pkgs, ... }: { - nixpkgs.overlays = [ overlay-unstable-aarch64 ]; + + ({ config, ... }: { + config = { + nixpkgs.overlays = [ overlay-unstable ]; + nixpkgs.config.allowUnfree = true; + home-manager = { + useGlobalPkgs = true; + users.winston.imports = [ ./home.nix ]; + extraSpecialArgs = { + nur = nur.nixosModules.nur; + sops = sops.homeManagerModules.sops; + machine = { + username = "winston"; + homeDirectory = "/Users/winston"; + personal = true; + flakePath = "/Users/winston/.config/nixpkgs"; + }; + }; + }; + }; }) ]; }; }; - - homeConfigurations.winston = home-manager.lib.homeManagerConfiguration rec { - pkgs = import nixpkgs { - system = "aarch64-darwin"; - config.allowUnfree = true; - }; - - modules = [ - ./home.nix - sops.homeManagerModules.sops - nur.nixosModules.nur - ({ config, pkgs, ... }: { - nixpkgs.overlays = [ overlay-unstable-aarch64 ]; - }) - ]; - extraSpecialArgs = { - machine = { - username = "winston"; - homeDirectory = "/Users/winston"; - personal = true; - flakePath = "/Users/winston/.config/nixpkgs"; - }; - }; - }; }; } diff --git a/home.nix b/home.nix index cbc7464..76ca378 100644 --- a/home.nix +++ b/home.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, machine, ... }: +{ config, lib, nur, pkgs, sops, machine, ... }: let inherit (pkgs.stdenv.hostPlatform) isLinux; @@ -7,6 +7,8 @@ in { imports = [ + nur + sops ./catppuccin ./modules/firefox.nix ./modules/git.nix @@ -26,8 +28,6 @@ in ./modules/secrets.nix ]; - nixpkgs.config.allowUnfreePredicate = (pkg: true); - catppuccin = { defaultTheme = "frappe"; bat.enable = true; @@ -39,9 +39,6 @@ in manual.manpages.enable = false; home = { - homeDirectory = machine.homeDirectory; - username = machine.username; - packages = with pkgs; ([ zsh fd ffmpeg file imagemagick mdcat ranger ripgrep @@ -51,7 +48,7 @@ in (callPackage ./packages/org-stats {}) (callPackage ./packages/python3.catppuccin-catwalk {}) (nerdfonts.override { fonts = ["NerdFontsSymbolsOnly"]; }) - pkgs.unstable.wezterm + unstable.wezterm (callPackage ./packages/helm-ls {}) ] ++ lib.optionals isDarwin [ iina @@ -61,7 +58,7 @@ in mattermost-desktop ] ++ lib.optionals (isLinux && machine.personal) [ (callPackage ./packages/python3.discover-overlay {}) - pkgs.unstable.discord + unstable.discord lutris ]); diff --git a/justfile b/justfile index 654a003..b4925c0 100644 --- a/justfile +++ b/justfile @@ -1,12 +1,13 @@ [macos] -switch: +switch: secret-stage && secret-unstage darwin-rebuild switch --flake . [linux] -switch: +switch: secret-stage && secret-unstage nixos-rebuild switch --flake . -home: +secret-stage: git add -f modules/secrets.nix - home-manager switch --flake . + +secret-unstage: git restore --staged modules/secrets.nix diff --git a/modules/firefox.nix b/modules/firefox.nix index 143e1bd..eee2db6 100644 --- a/modules/firefox.nix +++ b/modules/firefox.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ config, lib, nur, pkgs, ... }: let inherit (pkgs.stdenv.hostPlatform) isLinux; diff --git a/modules/mail.nix b/modules/mail.nix index 45bc1bb..e9b18e3 100644 --- a/modules/mail.nix +++ b/modules/mail.nix @@ -5,18 +5,6 @@ let in { - nixpkgs.overlays = [(self: super: { - meli = super.meli.overrideAttrs (old: { - buildInputs = old.buildInputs ++ lib.optionals isDarwin [ - pkgs.darwin.apple_sdk.frameworks.CoreServices - ]; - meta = old.meta // { - platforms = lib.platforms.linux ++ lib.platforms.darwin; - broken = false; - }; - }); - })]; - accounts.email.maildirBasePath = "${config.xdg.dataHome}/mail"; accounts.email.accounts = { diff --git a/modules/neovim.nix b/modules/neovim.nix index 419b8ae..c811c53 100644 --- a/modules/neovim.nix +++ b/modules/neovim.nix @@ -53,7 +53,7 @@ ltex-ls nodePackages.prettier rnix-lsp - pkgs.unstable.rust-analyzer + unstable.rust-analyzer proselint rustc rustfmt diff --git a/modules/sketchybar.nix b/modules/sketchybar.nix index 5f5aa4f..92660fc 100644 --- a/modules/sketchybar.nix +++ b/modules/sketchybar.nix @@ -1,4 +1,4 @@ -{ config, pkgs, lib, ... }: +{ config, lib, ... }: { home = lib.mkIf isDarwin { diff --git a/shell.nix b/shell.nix index 7939edf..dc63edf 100644 --- a/shell.nix +++ b/shell.nix @@ -2,6 +2,8 @@ let pkgs = import {}; in pkgs.mkShell { buildInputs = with pkgs; [ + git + git-secret just ]; }