Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
rake5k committed Dec 19, 2023
1 parent 78fe8a1 commit 590ee3c
Show file tree
Hide file tree
Showing 27 changed files with 212 additions and 35 deletions.
28 changes: 24 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 19 additions & 9 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
flake-utils.url = "github:numtide/flake-utils";

home-manager = {
url = "github:nix-community/home-manager/release-23.11";
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};

darwin = {
url = "github:lnl7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};

Expand Down Expand Up @@ -82,25 +87,29 @@
nixcfgLib = import ./lib {
inherit inputs;
};
inherit (inputs.flake-utils.lib.system) x86_64-linux;
inherit (inputs.flake-utils.lib.system) aarch64-darwin aarch64-linux x86_64-linux;
inherit (nixpkgs.lib) listToAttrs;
in
with nixcfgLib;
{
lib = { inputs }:
import ./lib { inputs = inputs // self.inputs; };

darwinConfigurations = listToAttrs [
(mkNixDarwin aarch64-darwin "macos")
];

homeConfigurations = listToAttrs [
(mkHome x86_64-linux "demo@non-nixos-vm")
(mkHome x86_64-linux "christian@non-nixos-vm")
(mkHome x86_64-linux "christian@non-nixos")
(mkHome x86_64-linux "demo@non-nixos")
];

nixosConfigurations = listToAttrs [
(mkNixos x86_64-linux "nixos-vm")
(mkNixos x86_64-linux "nixos")
];

nixOnDroidConfigurations = listToAttrs [
(mkNixOnDroid "aarch64-linux" "nix-on-droid")
(mkNixOnDroid aarch64-linux "nix-on-droid")
];

apps = mkForEachSystem [
Expand Down Expand Up @@ -163,9 +172,10 @@
};
}))

(mkBuild "build-nixos-vm" self.nixosConfigurations.nixos-vm.config.system.build.toplevel)
(mkBuild "build-demo@non-nixos-vm" self.homeConfigurations."demo@non-nixos-vm".activationPackage)
(mkBuild "build-christian@non-nixos-vm" self.homeConfigurations."christian@non-nixos-vm".activationPackage)
(mkBuild "build-christian@non-nixos" self.homeConfigurations."christian@non-nixos".activationPackage)
(mkBuild "build-demo@non-nixos" self.homeConfigurations."demo@non-nixos".activationPackage)
(mkBuild "build-macos" self.darwinConfigurations."macos".system)
(mkBuild "build-nixos" self.nixosConfigurations.nixos.config.system.build.toplevel)
];

devShells = mkForEachSystem [
Expand Down
8 changes: 7 additions & 1 deletion home/base/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{ config, lib, ... }:

let

inherit (config.custom.base.non-nixos) isDarwin;

in

{
home = {
homeDirectory = lib.mkDefault "/home/${config.home.username}";
Expand All @@ -11,7 +17,7 @@
enableNixpkgsReleaseCheck = true;
};

xdg.userDirs = {
xdg.userDirs = lib.mkIf (!isDarwin) {
enable = true;
createDirectories = true;
};
Expand Down
11 changes: 10 additions & 1 deletion home/base/non-nixos/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ in
enable = mkEnableOption "Config for non NixOS systems";

installNix = mkEnableOption "Nix installation" // { default = true; };

isDarwin = mkEnableOption "Darwin architecture (MacOS)";
};
};

Expand Down Expand Up @@ -48,8 +50,15 @@ in

programs.zsh.envExtra = mkAfter ''
hash -f
''
+ optionalstring cfg.isDarwin ''
# Nix
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi
# End Nix
'';

targets.genericLinux.enable = true;
targets.genericLinux.enable = !cfg.isDarwin;
};
}
4 changes: 2 additions & 2 deletions home/base/system/filesystems/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ pkgs, ... }:
{ config, lib, pkgs, ... }:

{
lib.mkIf (!config.custom.base.non-nixos.isDarwin) {
home.packages = with pkgs; [
parted
exfat
Expand Down
4 changes: 3 additions & 1 deletion home/base/system/udiskie/default.nix
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{ config, ... }:

{
services.udiskie.enable = true;
services.udiskie.enable = !config.custom.base.non-nixos.isDarwin;
}
2 changes: 1 addition & 1 deletion home/roles/desktop/locker/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ in
};
};

config = {
config = mkIf desktopCfg.enable {
home.packages = [
cfg.package
] ++ (with pkgs; [
Expand Down
2 changes: 2 additions & 0 deletions home/roles/graphics/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ in
config = mkIf cfg.enable {
home.packages = with pkgs; [
gimp
]
++ optionals (!config.custom.base.non-nixos.isDarwin) [
sxiv
];
};
Expand Down
4 changes: 3 additions & 1 deletion home/roles/office/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ in
custom.roles.office.cli.enable = true;

home.packages = with pkgs; [
libreoffice
reveal-md
]
++ optionals (!config.custom.base.non-nixos.isDarwin) [
libreoffice
];
};
}
13 changes: 8 additions & 5 deletions home/roles/web/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ let

cfg = config.custom.roles.web;

inherit (config.custom.base.non-nixos) isDarwin;

in

{
Expand All @@ -18,7 +20,8 @@ in
config = mkIf cfg.enable {
custom = {
programs.firefox = {
enable = true;
# See: https://github.com/NixOS/nixpkgs/issues/71689
enable = !isDarwin;
extensions = with pkgs.nur.repos.rycee.firefox-addons; [
consent-o-matic
facebook-container
Expand All @@ -33,16 +36,16 @@ in
ublock-origin
];
};
roles.web.nextcloud-client.enable = true;
roles.web.nextcloud-client.enable = !isDarwin;
};

home.packages = with pkgs; [
_1password
_1password-gui
bind
thunderbird
wget

]
++ optionals (!isDarwin) [
# Messengers
signal-desktop
telegram-desktop
Expand All @@ -52,6 +55,6 @@ in
freetube
];

programs.chromium.enable = true;
programs.chromium.enable = !isDarwin;
};
}
2 changes: 1 addition & 1 deletion home/users/christian/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ in
fonts.enable = !config.custom.roles.mobile.enable;
git.enable = true;
gpg.enable = true;
hardware = {
hardware = mkIf (!config.custom.base.non-nixos.isDarwin) {
kmonad.enable = !config.custom.roles.mobile.enable;
xbindkeys.enable = !config.custom.roles.mobile.enable;
};
Expand Down
2 changes: 0 additions & 2 deletions home/users/christian/shell/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ in
packages = with pkgs; [
# Terminal fun
asciiquarium
bb
cowsay
cmatrix
figlet
Expand All @@ -44,7 +43,6 @@ in
fd # ultra-fast find
ripgrep

convmv
curl
eva
file
Expand Down
21 changes: 21 additions & 0 deletions hosts/macos/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{ pkgs, ... }:

{
custom.base.users = [ "chr" ];

# if you use zsh (the default on new macOS installations),
# you'll need to enable this so nix-darwin creates a zshrc sourcing needed environment changes
programs.zsh.enable = true;

# Homebrew
homebrew = {
enable = true;
onActivation = {
autoUpdate = true;
upgrade = true;
};
casks = [
"alfred"
];
};
}
21 changes: 21 additions & 0 deletions hosts/macos/home-chr.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
custom = {
base.non-nixos = {
enable = true;
isDarwin = true;
};

users.christian.enable = true;

roles = {
dev.enable = true;
graphics.enable = true;
homeage.enable = true;
office.enable = true;
ops.enable = true;
web.enable = true;
};
};

home.stateVersion = import ./state-version.nix;
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions hosts/non-nixos/state-version.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"23.11"
27 changes: 27 additions & 0 deletions lib/builders/mkNixDarwin.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{ inputs, system, pkgs, customLib, homeModules, name, ... }:

inputs.darwin.lib.darwinSystem {
inherit system;

specialArgs = {
inherit homeModules inputs;
};

modules = [
inputs.home-manager.darwinModules.home-manager
"${inputs.self}/hosts/${name}"

{
custom.base.hostname = name;

lib.custom = customLib;

nixpkgs = {
inherit pkgs;
};
}
]
++ customLib.getRecursiveDefaultNixFileList ../../nix-darwin
++ customLib.getRecursiveDefaultNixFileList "${inputs.self}/nix-darwin";
}

Loading

0 comments on commit 590ee3c

Please sign in to comment.