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.
# $ darwin-rebuild changelog
system.stateVersion = 4;

View file

@ -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"
}

View file

@ -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";
};
};
};
};
}

View file

@ -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
]);

View file

@ -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

View file

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

View file

@ -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 = {

View file

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

View file

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

View file

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