-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
74 lines (69 loc) · 2.33 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
{
description = "Robert's darwin config";
inputs = {
# base imports
utils.url = "github:numtide/flake-utils";
# nixos/nix-darwin dependencies
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
nixpkgs-darwin.url = "github:NixOS/nixpkgs/nixpkgs-24.05-darwin";
nixpkgs-master.url = "github:NixOS/nixpkgs/master";
home-manager = {
url = "github:nix-community/home-manager/release-24.05";
inputs.nixpkgs.follows = "nixpkgs";
};
darwin = {
url = "github:lnl7/nix-darwin/master";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
inputs@{ self, darwin, nixpkgs-darwin, nixpkgs, home-manager, utils, ... }:
let
inherit (darwin.lib) darwinSystem;
inherit (inputs.nixpkgs.lib)
attrValues makeOverridable optionalAttrs singleton;
defaultSystems = [ "aarch64-darwin" ];
# Configuration for `nixpkgs`
nixpkgsConfig = {
config = { allowUnfree = true; };
overlays = attrValues self.overlays ++ singleton (
# Sub in x86 version of packages that don't build on Apple Silicon yet
final: prev:
(optionalAttrs (prev.stdenv.system == "aarch64-darwin") {
inherit (final.pkgs-x86)
;
}));
};
in {
darwinConfigurations = rec {
robert = darwinSystem {
system = "aarch64-darwin";
modules = [
# Main `nix-darwin` config
./darwin
# `home-manager` module
home-manager.darwinModules.home-manager
({ config, lib, pkgs, ... }:
let primaryUser = "robert";
in {
nixpkgs = nixpkgsConfig;
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
users.users.${primaryUser}.home = "/Users/${primaryUser}";
home-manager.users.robert = import ./home-manager;
})
];
};
};
overlays = {
apple-silicon = final: prev:
optionalAttrs (prev.stdenv.system == "aarch64-darwin") {
# Add access to x86 packages system is running Apple Silicon
pkgs-x86 = import inputs.nixpkgs-unstable {
system = "x86_64-darwin";
inherit (nixpkgsConfig) config;
};
};
};
};
}