Skip to content

Commit

Permalink
refactor flake
Browse files Browse the repository at this point in the history
  • Loading branch information
tomodachi94 committed Apr 6, 2024
1 parent 81889c9 commit 7e3347d
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 78 deletions.
105 changes: 27 additions & 78 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
description = "Home Manager configuration of Tomodachi94";

inputs = {
# Specify the source of Home Manager and Nixpkgs.
nixpkgs = {
url = "github:nixos/nixpkgs/nixpkgs-unstable";
inputs = { };
};

nixos-hardware = {
nixos-hardware = {
url = "github:nixos/nixos-hardware";
};
};

home-manager = {
url = "github:nix-community/home-manager/master";
Expand All @@ -35,92 +34,42 @@

zsh-craftos-select = {
url = "git+https://gist.github.com/tomodachi94/aaae79f7cb4e7b2087727fbbfe05eb12";
inputs.nixpkgs.follows = "nixpkgs";
};
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { nixpkgs, nixos-hardware, home-manager, nur, tomodachi94, mac-app-util, nix-craftos-pc, zsh-craftos-select, ... }:
let
forAllSystems = function:
nixpkgs.lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
]
(system: function nixpkgs.legacyPackages.${system});
tomolib = import ./lib { inherit nixpkgs home-manager; };

vars = import ./vars;
vars = import ./lib/vars.nix;

bases.hp-laptop-df0023 = let
hw = nixos-hardware.nixosModules;
in [
home-manager.nixosModules.home-manager
./hosts/hp-laptop-df0023
hw.common-cpu-intel
hw.common-cpu-intel-sandy-bridge
hw.common-pc
hw.common-pc-laptop
# Note: This laptop had its HDD replaced with an SSD
hw.common-pc-laptop-ssd
commonInputs = { inherit vars tomodachi94; };

homeCommonInputs = commonInputs // { inherit zsh-craftos-select; };
homeLinuxInputs = homeCommonInputs // { inherit nix-craftos-pc; };
homeDarwinInputs = homeCommonInputs // { inherit mac-app-util; };

{
home-manager.users.me = { pkgs, vars, ... }: {
imports = [ ./home/common ./home/linux ];
};
home-manager.extraSpecialArgs = { inherit vars zsh-craftos-select; };
}
];
systemCommonInputs = commonInputs // { };
systemLinuxInputs = systemCommonInputs // { nixos-hardware = nixos-hardware.nixosModules; homeInputs = homeCommonInputs; };
systemDarwinInputs = systemCommonInputs // { };

in
{
homeConfigurations.darwin-aarch64 = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.aarch64-darwin;
homeConfigurations.darwin-aarch64 = tomolib.mkHMConfig { systemType = "darwin"; systemArch = "aarch64"; args = homeDarwinInputs; };
homeConfigurations.darwin-x86_64 = tomolib.mkHMConfig { systemType = "darwin"; systemArch = "x86_64"; args = homeDarwinInputs; };
homeConfigurations.linux-aarch64 = tomolib.mkHMConfig { systemType = "linux"; systemArch = "aarch64"; args = homeDarwinInputs; };
homeConfigurations.linux-x86_64 = tomolib.mkHMConfig { systemType = "linux"; systemArch = "x86_64"; args = homeDarwinInputs; };

# Specify your home configuration modules here, for example,
# the path to your home.nix.
modules = [
./home/common
./home/darwin
];

# Optionally use extraSpecialArgs
# to pass through arguments to home.nix
extraSpecialArgs = {
inherit nixos-hardware nur tomodachi94 mac-app-util;
};
};

nixosConfigurations = {
/* hp-laptop-df0023-iso = nixpkgs.lib.nixosSystem {
specialArgs = { };
modules = bases.hp-laptop-df0023 ++ [ "${nixpkgs.outPath}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix" ];
}; */
hp-laptop-df0023 = nixpkgs.lib.nixosSystem {
specialArgs = { inherit vars; };
modules = bases.hp-laptop-df0023;
};
};
nixosConfigurations.hp-laptop-df0023 = tomolib.mkNixosConfig { hostname = "hp-laptop-df0023"; systemArch = "x86_64"; args = systemLinuxInputs; extraModules = let hw = nixos-hardware.nixosModules; in [
hw.common-cpu-intel
hw.common-cpu-intel-sandy-bridge
hw.common-pc
hw.common-pc-laptop
# Note: This laptop had its HDD replaced with an SSD
hw.common-pc-laptop-ssd
]; };

devShells = forAllSystems (pkgs: {
default = pkgs.mkShell {
packages = with pkgs; [
nixos-rebuild
just
stylua
deadnix
nixpkgs-fmt
selene
home-manager.packages.${system}.default
];
};
ci = pkgs.mkShell {
packages = with pkgs; [
just
nixos-rebuild
jq
];
};
});
devShells = tomolib.forAllSystems (pkgs: import ./lib/shells.nix { inherit pkgs home-manager; } );
};
}
3 changes: 3 additions & 0 deletions home/linux/i3/colors.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# i3 configuration


7 changes: 7 additions & 0 deletions hosts/hp-laptop-df0023/default.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
{ vars, homeInputs, ... }:
{
imports = [
./hardware-configuration.nix
../../nixos
];

home-manager.users.me = { pkgs, vars, ... }: {
imports = [ ../../home/common ../../home/linux ];
};

home-manager.extraSpecialArgs = homeInputs;

home-manager.useUserPackages = true;

networking.hostName = "hp-laptop-df0023"; # Define your hostname.
Expand Down
File renamed without changes.
35 changes: 35 additions & 0 deletions lib/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{ nixpkgs, home-manager }:
rec {
mkHMImports = systemType: [ ../home/common (../. + "home/${systemType}") ];
mkNixpkgs = { systemType, systemArch }: nixpkgs.legacyPackages."${systemArch}-${systemType}";

forAllSystems = function:
nixpkgs.lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
]
(system: function nixpkgs.legacyPackages.${system});

mkHMConfig = { systemType, systemArch, args }: home-manager.lib.homeManagerConfiguration {
pkgs = mkNixpkgs { inherit systemType systemArch; };

# Specify your home configuration modules here, for example,
# the path to your home.nix.
modules = mkHMImports systemType;

# Optionally use extraSpecialArgs
# to pass through arguments to home.nix
extraSpecialArgs = args;
};

mkNixosConfig = { systemArch, hostname, extraModules, args }: nixpkgs.lib.nixosSystem {
specialArgs = args;
modules = [
(../hosts + "/${hostname}")
home-manager.nixosModules.home-manager
] ++ extraModules;
};

}
22 changes: 22 additions & 0 deletions lib/shells.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{ pkgs, home-manager, ... }:
{

default = pkgs.mkShell {
packages = with pkgs; [
nixos-rebuild
just
stylua
deadnix
nixpkgs-fmt
selene
home-manager.packages.${system}.default
];
};
ci = pkgs.mkShell {
packages = with pkgs; [
just
nixos-rebuild
jq
];
};
}
File renamed without changes.

0 comments on commit 7e3347d

Please sign in to comment.