feat: use home-manager as a nix-darwin module

This commit is contained in:
winston 2023-02-10 06:29:23 +01:00
parent d95b80957b
commit 300d7aa00a
Signed by: winston
GPG key ID: 3786770EDBC2B481
10 changed files with 53 additions and 107 deletions

View file

@ -12,6 +12,8 @@
}; };
}; };
users.users.winston.home = "/Users/winston";
# Used for backwards compatibility, please read the changelog before changing. # Used for backwards compatibility, please read the changelog before changing.
# $ darwin-rebuild changelog # $ darwin-rebuild changelog
system.stateVersion = 4; system.stateVersion = 4;

View file

@ -21,20 +21,6 @@
"type": "github" "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": { "home-manager": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -73,18 +59,18 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs-22_05": { "nixpkgs-stable": {
"locked": { "locked": {
"lastModified": 1656955776, "lastModified": 1676003493,
"narHash": "sha256-1aMu67m+orlGxVwfiX3RxTEVFoq/RmKa/L5u9zU3UNQ=", "narHash": "sha256-D7al8mRCMBu6eOF62Nlx1jzCSU6odbBK/OJVynqnMHc=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "cc16da2c92041cbe817c40f62aac87c99104e9c2", "rev": "8866a38d4d24542f2a355b6b2c7591a4bc78b343",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "owner": "NixOS",
"ref": "release-22.05", "ref": "release-22.11",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
@ -140,7 +126,6 @@
"root": { "root": {
"inputs": { "inputs": {
"darwin": "darwin", "darwin": "darwin",
"flake-utils": "flake-utils",
"home-manager": "home-manager", "home-manager": "home-manager",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nixpkgs-unstable": "nixpkgs-unstable", "nixpkgs-unstable": "nixpkgs-unstable",
@ -151,19 +136,19 @@
"sops": { "sops": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs_2", "nixpkgs": "nixpkgs_2",
"nixpkgs-22_05": "nixpkgs-22_05" "nixpkgs-stable": "nixpkgs-stable"
}, },
"locked": { "locked": {
"lastModified": 1675284668, "lastModified": 1675872570,
"narHash": "sha256-wJMCAr3GV8GXVWnDTf06QdZRwe6zp8oD/X6PdIWS8/I=", "narHash": "sha256-RPH3CeTv7ixC2WcYiKyhmIgoH/9tur4Kr+3Vg/pleQk=",
"owner": "Mic92", "owner": "Mic92",
"repo": "sops-nix", "repo": "sops-nix",
"rev": "9d523ff9cf0d9c3ad097443491fe7ed2187b17ed", "rev": "8fec29b009c19538e68d5d814ec74e04f662fbd1",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "Mic92", "owner": "Mic92",
"ref": "feat/home-manager", "ref": "master",
"repo": "sops-nix", "repo": "sops-nix",
"type": "github" "type": "github"
} }

View file

@ -15,13 +15,12 @@
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
nur.url = "github:nix-community/NUR/master"; nur.url = "github:nix-community/NUR/master";
sops.url = "github:Mic92/sops-nix/feat/home-manager"; sops.url = "github:Mic92/sops-nix/master";
}; };
outputs = { outputs = {
self, self,
darwin, darwin,
flake-utils,
home-manager, home-manager,
nixpkgs, nixpkgs,
nixpkgs-unstable, nixpkgs-unstable,
@ -30,72 +29,44 @@
... ...
}: }:
let let
overlay-unstable-x86-64 = final: prev: { overlay-unstable = final: prev: {
unstable = import nixpkgs-unstable { unstable = import nixpkgs-unstable {
system = "x86_64-linux"; system = prev.system;
config.allowUnfree = true; config.allowUnfree = true;
}; };
}; };
overlay-unstable-aarch64 = final: prev: { in {
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
# ];
# };
# };
darwinConfigurations = { darwinConfigurations = {
"sashimi-slicer" = darwin.lib.darwinSystem rec { "sashimi-slicer" = darwin.lib.darwinSystem rec {
system = "aarch64-darwin"; system = "aarch64-darwin";
# pkgs = import nixpkgs {
# inherit system;
# config.allowUnfree = true;
# };
modules = [ modules = [
home-manager.darwinModules.home-manager
./darwin.nix ./darwin.nix
# make "pkgs.unstable" available
({ config, pkgs, ... }: { ({ config, ... }: {
nixpkgs.overlays = [ overlay-unstable-aarch64 ]; 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";
};
};
};
}; };
} }

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, machine, ... }: { config, lib, nur, pkgs, sops, machine, ... }:
let let
inherit (pkgs.stdenv.hostPlatform) isLinux; inherit (pkgs.stdenv.hostPlatform) isLinux;
@ -7,6 +7,8 @@ in
{ {
imports = [ imports = [
nur
sops
./catppuccin ./catppuccin
./modules/firefox.nix ./modules/firefox.nix
./modules/git.nix ./modules/git.nix
@ -26,8 +28,6 @@ in
./modules/secrets.nix ./modules/secrets.nix
]; ];
nixpkgs.config.allowUnfreePredicate = (pkg: true);
catppuccin = { catppuccin = {
defaultTheme = "frappe"; defaultTheme = "frappe";
bat.enable = true; bat.enable = true;
@ -39,9 +39,6 @@ in
manual.manpages.enable = false; manual.manpages.enable = false;
home = { home = {
homeDirectory = machine.homeDirectory;
username = machine.username;
packages = with pkgs; ([ packages = with pkgs; ([
zsh zsh
fd ffmpeg file imagemagick mdcat ranger ripgrep fd ffmpeg file imagemagick mdcat ranger ripgrep
@ -51,7 +48,7 @@ in
(callPackage ./packages/org-stats {}) (callPackage ./packages/org-stats {})
(callPackage ./packages/python3.catppuccin-catwalk {}) (callPackage ./packages/python3.catppuccin-catwalk {})
(nerdfonts.override { fonts = ["NerdFontsSymbolsOnly"]; }) (nerdfonts.override { fonts = ["NerdFontsSymbolsOnly"]; })
pkgs.unstable.wezterm unstable.wezterm
(callPackage ./packages/helm-ls {}) (callPackage ./packages/helm-ls {})
] ++ lib.optionals isDarwin [ ] ++ lib.optionals isDarwin [
iina iina
@ -61,7 +58,7 @@ in
mattermost-desktop mattermost-desktop
] ++ lib.optionals (isLinux && machine.personal) [ ] ++ lib.optionals (isLinux && machine.personal) [
(callPackage ./packages/python3.discover-overlay {}) (callPackage ./packages/python3.discover-overlay {})
pkgs.unstable.discord unstable.discord
lutris lutris
]); ]);

View file

@ -1,12 +1,13 @@
[macos] [macos]
switch: switch: secret-stage && secret-unstage
darwin-rebuild switch --flake . darwin-rebuild switch --flake .
[linux] [linux]
switch: switch: secret-stage && secret-unstage
nixos-rebuild switch --flake . nixos-rebuild switch --flake .
home: secret-stage:
git add -f modules/secrets.nix git add -f modules/secrets.nix
home-manager switch --flake .
secret-unstage:
git restore --staged modules/secrets.nix git restore --staged modules/secrets.nix

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }: { config, lib, nur, pkgs, ... }:
let let
inherit (pkgs.stdenv.hostPlatform) isLinux; inherit (pkgs.stdenv.hostPlatform) isLinux;

View file

@ -5,18 +5,6 @@ let
in 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.maildirBasePath = "${config.xdg.dataHome}/mail";
accounts.email.accounts = { accounts.email.accounts = {

View file

@ -53,7 +53,7 @@
ltex-ls ltex-ls
nodePackages.prettier nodePackages.prettier
rnix-lsp rnix-lsp
pkgs.unstable.rust-analyzer unstable.rust-analyzer
proselint proselint
rustc rustc
rustfmt rustfmt

View file

@ -1,4 +1,4 @@
{ config, pkgs, lib, ... }: { config, lib, ... }:
{ {
home = lib.mkIf isDarwin { home = lib.mkIf isDarwin {

View file

@ -2,6 +2,8 @@ let pkgs = import <nixpkgs> {}; in
pkgs.mkShell { pkgs.mkShell {
buildInputs = with pkgs; [ buildInputs = with pkgs; [
git
git-secret
just just
]; ];
} }