Skip to content

Commit

Permalink
Add support for aarch64-linux
Browse files Browse the repository at this point in the history
  • Loading branch information
KubqoA committed Sep 12, 2024
1 parent f36efbc commit d31868b
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 18 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Further the dotfiles include:
## Usage
The dotfiles contain configuration for:
- [harmonium](./hosts/harmonium) - Personal NixOS laptop setup
- [organ](./hosts/organ) - ARM-based server
- [nyckelharpa](./hosts/nyckelharpa) - Work MacOS setup
- home-manager configurations for both systems

Expand Down
11 changes: 6 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@
formatter = lib.formatter;

# home-manager configurations defined in a flake can be enabled by running
# $ nix run home-manager/master -- switch --flake dotfiles
# or in case of username mismatch, e.g. jakub vs jakub-macos
# $ nix run home-manager/master -- switch --flake "dotfiles#jakub-macos"
homeConfigurations.jakub = lib.linuxHome ./users/jakub-linux;
homeConfigurations.jakub-x86 = lib.linuxHome-x86 ./users/jakub-linux;
homeConfigurations.jakub-arm64 = lib.linuxHome-arm64 ./users/jakub-linux;
homeConfigurations.jakub-macos = lib.macosHome ./users/jakub-macos;

# nixos configurations defined in a flake can be enabled by running
# $ nixos-rebuild switch --flake dotfiles
nixosConfigurations.harmonium = lib.nixosSystem ./hosts/harmonium;
# $ nixos-rebuild switch --flake dotfiles#harmonium
# $ nixos-rebuild switch --flake dotfiles#organ
nixosConfigurations.harmonium = lib.nixosSystem-x86 ./hosts/harmonium;
nixosConfigurations.organ = lib.nixosSystem-arm64 ./hosts/organ;

# nix-darwin configurations defined in a flake can be enabled by running
# $ darwin-rebuild build --flake dotfiles#nyckelharpa
Expand Down
6 changes: 6 additions & 0 deletions hosts/organ/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
![Organ](./organ.jpg)

<sub><sup>Photo by <a href="https://unsplash.com/@haozlife?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash">Hao Zhang</a> on <a href="https://unsplash.com/photos/man-playing-brown-musical-instrument-dFpDCSECapg?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash">Unsplash</a></sup></sub>

# organ
ARM-based server running on Hetzner cloud
1 change: 1 addition & 0 deletions hosts/organ/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{...}: {}
Binary file added hosts/organ/organ.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
Library has two important functions:

1. Moves configuration boilerplate out of the main `flake.nix` by providing
`macosHome`, `linuxHome`, `macosSystem` and `nixosSystem` functions to
define home-manager and system configurations
`macosHome`, `linuxHome-x86`, `linuxHome-arm64`, `macosSystem`,
`nixosSystem-x86` and `nixosSystem-arm64` functions to define home-manager
and system configurations

2. Autoloads [`config.nix`](../config.nix) for all these configurations

Expand Down
21 changes: 13 additions & 8 deletions lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ inputs @ {
self,
...
}: let
linuxSystem = "x86_64-linux";
macosSystem = "aarch64-darwin";
linuxPkgs = makePkgs linuxSystem;
linuxSystem-x86 = "x86_64-linux";
linuxSystem-arm64 = "aarch64-linux";
macosPkgs = makePkgs macosSystem;
linuxPkgs-x86 = makePkgs linuxSystem-x86;
linuxPkgs-arm64 = makePkgs linuxSystem-arm64;

makePkgs = system:
import nixpkgs {
Expand All @@ -34,11 +36,11 @@ inputs @ {
}
// extra);

makeHome = pkgs: path:
makeHome = system: pkgs: path:
home-manager.lib.homeManagerConfiguration {
inherit pkgs;
extraSpecialArgs = {
inherit inputs;
inherit inputs system;
# Make sure to keep library extensions from home-manager
lib = makeLib pkgs home-manager.lib;
};
Expand All @@ -57,12 +59,15 @@ inputs @ {
in {
formatter = {
${macosSystem} = macosPkgs.alejandra;
${linuxSystem} = linuxPkgs.alejandra;
${linuxSystem-x86} = linuxPkgs-x86.alejandra;
${linuxSystem-arm64} = linuxPkgs-arm64.alejandra;
};

macosHome = makeHome macosPkgs;
linuxHome = makeHome linuxPkgs;
macosHome = makeHome macosSystem macosPkgs;
linuxHome-x86 = makeHome linuxSystem-x86 linuxPkgs-x86;
linuxHome-arm64 = makeHome linuxSystem-arm64 linuxPkgs-arm64;

macosSystem = makeSystem (nix-darwin.lib.darwinSystem) macosSystem macosPkgs;
nixosSystem = makeSystem (nixpkgs.lib.nixosSystem) linuxSystem linuxPkgs;
nixosSystem-x86 = makeSystem (nixpkgs.lib.nixosSystem) linuxSystem-x86 linuxPkgs-x86;
nixosSystem-arm64 = makeSystem (nixpkgs.lib.nixosSystem) linuxSystem-arm64 linuxPkgs-arm64;
}
22 changes: 21 additions & 1 deletion modules/common/aliases.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,26 @@
{
config,
lib,
system,
...
}: {
home.shellAliases = {
home.shellAliases = let
username = config.home.username;
dotfiles =
{
"x86_64-linux" = "/persist/dotfiles";
"aarch64-linux" = "/persist/dotfiles";
"aarch64-darwin" = "$HOME/.config/dotfiles";
}
.${system};
homeConfig =
{
"x86_64-linux" = "${username}-x86";
"aarch64-linux" = "${username}-arm64";
"aarch64-darwin" = "${username}-macos";
}
.${system};
in {
cd = lib.mkIf config.programs.zoxide.enable "z";
ls = "ls --color=tty";
chx = "chmod +x";
Expand All @@ -30,5 +47,8 @@

# Utils
benchzsh = "hyperfine 'zsh -i -c exit' --warmup 1";
hm = "home-manager --flake \"${dotfiles}#${homeConfig}\"";
dots = "$EDITOR \"${dotfiles}\"";
zd = "cd \"${dotfiles}\"";
};
}
1 change: 1 addition & 0 deletions users/jakub-linux/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
inputs,
lib,
pkgs,
system,
...
}: {
imports = lib._.moduleImports [
Expand Down
2 changes: 0 additions & 2 deletions users/jakub-macos/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@
};

shellAliases = {
hm = "home-manager --flake \"$HOME/.config/dotfiles#jakub-macos\"";
dw = "darwin-rebuild --flake \"$HOME/.config/dotfiles\"";
dots = "$EDITOR ~/.config/dotfiles";

# Work
linear = "git checkout main && git pull && git checkout -b $(pbpaste)";
Expand Down

0 comments on commit d31868b

Please sign in to comment.