-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
990b86b
commit 9842f7e
Showing
4 changed files
with
128 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
home = { | ||
username = "william"; | ||
fullname = "William Hsieh"; | ||
email = "wh31110@gmail.com"; | ||
dotDir = "dotfiles"; # path relative to $HOME, this example represents `~/dotfiles` | ||
wsl = false; | ||
gui = false; | ||
}; | ||
|
||
nixos = { | ||
# enable = true; | ||
hostname = "nixos-local"; | ||
system = "x86_64-linux"; | ||
}; | ||
|
||
darwin = { | ||
# enable = true; | ||
hostname = "macos-local"; | ||
system = "aarch64-darwin"; | ||
}; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,62 @@ | ||
{ inputs, ... }: | ||
with inputs.nixpkgs.lib; | ||
let | ||
lockfile = builtins.fromJSON (builtins.readFile ../flake.lock); | ||
inherit (inputs.nixpkgs) lib; | ||
|
||
dotfiles = import ../config.nix; | ||
|
||
foreachSystem = genAttrs [ "x86_64-linux" "aarch64-darwin" ]; | ||
|
||
pkgsBySystem = foreachSystem ( | ||
system: | ||
# https://github.com/nix-community/home-manager/issues/2942#issuecomment-1378627909 | ||
import inputs.nixpkgs { | ||
inherit system; | ||
config = { | ||
allowUnfree = true; | ||
allowUnfreePredicate = (_: true); | ||
packageOverrides = pkgs: { | ||
unstable = import inputs.nixpkgs-unstable { | ||
inherit (pkgs) system config; | ||
}; | ||
}; | ||
}; | ||
} | ||
); | ||
|
||
in | ||
{ | ||
stateVersion = "${builtins.elemAt (lib.splitString "-" lockfile.nodes.home-manager.original.ref) 1}"; | ||
|
||
mkSystem = { type }: | ||
let | ||
# TODO: assert type is either "darwin" or "nixos" | ||
isDarwin = type == "darwin"; | ||
osConfig = ../system/${if isDarwin then "darwin" else "nixos" }; | ||
userHMConfig = ../home; | ||
|
||
# NixOS vs nix-darwin functionst | ||
systemFunc = if isDarwin then inputs.darwin.lib.darwinSystem else inputs.nixpkgs.lib.nixosSystem; | ||
osModules = if isDarwin then inputs.home-manager.darwinModules else inputs.home-manager.nixosModules; | ||
|
||
hostSystem = if isDarwin then dotfiles.darwin else dotfiles.nixos; | ||
pkgs = pkgsBySystem.${hostSystem.system}; | ||
in | ||
{ | ||
${hostSystem.hostname} = systemFunc | ||
{ | ||
specialArgs = { inherit inputs pkgs dotfiles; }; | ||
modules = [ | ||
osConfig | ||
osModules.home-manager | ||
{ | ||
home-manager.useGlobalPkgs = true; | ||
# home-manager.useUserPackages = true; | ||
home-manager.extraSpecialArgs = { inherit inputs dotfiles; }; | ||
home-manager.users.${dotfiles.home.username} = import userHMConfig; | ||
} | ||
]; | ||
}; | ||
}; | ||
} |