mirror of
https://github.com/kogakure/dotfiles.git
synced 2026-02-03 20:25:30 +00:00
refactor(nix): improve reusability
This commit is contained in:
@@ -3,37 +3,57 @@
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
||||
|
||||
nix-darwin = {
|
||||
url = "github:LnL7/nix-darwin";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
home-manager = {
|
||||
url = "github:nix-community/home-manager";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
mac-app-util.url = "github:hraban/mac-app-util";
|
||||
};
|
||||
|
||||
outputs = { self, nix-darwin, home-manager, nixpkgs, mac-app-util }: {
|
||||
# Build darwin flake using:
|
||||
# $ darwin-rebuild switch --flake ~/.dotfiles/nix/.#mac-mini
|
||||
darwinConfigurations."mac-mini" = nix-darwin.lib.darwinSystem {
|
||||
outputs = { self, nix-darwin, home-manager, nixpkgs, mac-app-util }:
|
||||
let
|
||||
mkDarwinConfig = { system, hostname, username }:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
config.allowUnfree = true;
|
||||
};
|
||||
in
|
||||
nix-darwin.lib.darwinSystem {
|
||||
inherit system;
|
||||
specialArgs = { inherit pkgs; };
|
||||
modules = [
|
||||
./hosts/mac-mini/configuration.nix
|
||||
|
||||
./hosts/${hostname}/configuration.nix
|
||||
mac-app-util.darwinModules.default
|
||||
|
||||
home-manager.darwinModules.home-manager
|
||||
{
|
||||
home-manager.useGlobalPkgs = true;
|
||||
home-manager.useUserPackages = true;
|
||||
home-manager.verbose = true;
|
||||
home-manager.users.kogakure.imports = [ ./hosts/mac-mini/home.nix mac-app-util.homeManagerModules.default ];
|
||||
home-manager.users.${username} = {
|
||||
imports = [
|
||||
./hosts/${hostname}/home.nix
|
||||
mac-app-util.homeManagerModules.default
|
||||
];
|
||||
};
|
||||
home-manager.extraSpecialArgs = { inherit pkgs; };
|
||||
}
|
||||
];
|
||||
};
|
||||
in
|
||||
{
|
||||
# Build darwin flake using:
|
||||
# $ darwin-rebuild switch --flake ~/.dotfiles/nix/.#mac-mini
|
||||
darwinConfigurations = {
|
||||
"mac-mini" = mkDarwinConfig {
|
||||
system = "aarch64-darwin";
|
||||
hostname = "mac-mini";
|
||||
username = "kogakure";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user