From 5125e05266e5de73620b61350e8f040876f19c04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Wed, 22 Nov 2023 00:52:31 +0100 Subject: [PATCH] nix: Build on aarch64 --- config/nix/add_channels.sh | 6 ++++++ config/nix/build-pindakaas-image.sh | 19 ++++++++++++++++++- config/nix/build-vm.sh | 18 ++++++++++++++++++ config/nix/build.sh | 5 ----- config/nix/curacao.nix | 2 +- config/nix/hm/common.nix | 3 ++- config/nix/hm/desktop.nix | 13 +++++++------ config/nix/hm/dev.nix | 5 ++--- config/nix/hm/vim.nix | 6 +++--- config/nix/os/common.nix | 2 ++ config/nix/os/wireless.nix | 2 +- config/nix/pindakaas.nix | 5 ++--- config/nix/testvm.nix | 9 --------- 13 files changed, 62 insertions(+), 33 deletions(-) create mode 100755 config/nix/add_channels.sh create mode 100755 config/nix/build-vm.sh delete mode 100755 config/nix/build.sh delete mode 100644 config/nix/testvm.nix diff --git a/config/nix/add_channels.sh b/config/nix/add_channels.sh new file mode 100755 index 0000000..d5323e4 --- /dev/null +++ b/config/nix/add_channels.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +# TODO Surely there's more elegant? +nix-channel --add https://nixos.org/channels/nixos-23.05 nixpkgs +nix-channel --add https://github.com/nix-community/home-manager/archive/release-23.05.tar.gz home-manager +nix-channel --add https://github.com/NixOS/nixos-hardware/archive/master.tar.gz nixos-hardware diff --git a/config/nix/build-pindakaas-image.sh b/config/nix/build-pindakaas-image.sh index 4485564..2d679c5 100755 --- a/config/nix/build-pindakaas-image.sh +++ b/config/nix/build-pindakaas-image.sh @@ -1,3 +1,20 @@ #/usr/bin/env sh + +# Build a disk image for testing on pindakaas via sd card + export NIXPKGS_ALLOW_UNFREE=1 -nix-build '' -A config.system.build.sdImage -I nixos-config=./pindakaas.nix +extra="" +if [ "$(uname -m)" != "aarch64" ] +then + # If we have binfmt QEMU (https://nixos.wiki/wiki/NixOS_on_ARM#Compiling_through_binfmt_QEMU), + # we can pretend we're aarch64. + if [ -f /proc/sys/fs/binfmt_misc/qemu-aarch64 ] + then + extra="--argstr system aarch64-linux" + # Otherwise, use cross-compilation... + # theorically faster but doesn't use the cache and never got it to build a full customized image + else + extra="--argstr nixpkgs.crossSystem.system aarch64-linux" + fi +fi +nix-build '' -A config.system.build.sdImage -I nixos-config=./pindakaas.nix $extra --show-trace diff --git a/config/nix/build-vm.sh b/config/nix/build-vm.sh new file mode 100755 index 0000000..b1da329 --- /dev/null +++ b/config/nix/build-vm.sh @@ -0,0 +1,18 @@ +#/usr/bin/env sh + +# Build a NixOS VM for testing +# +# For x86_64 hosts: use curacao config +# For aarch64 hosts: use pindakaas config + +export NIXPKGS_ALLOW_UNFREE=1 +if [ "$(uname -m)" == "x86_64" ] +then + config=./curacao.nix +elif [ "$(uname -m)" == "aarch64" ] +then + config=./pindakaas.nix +fi +nix-build '' -A vm \ +-I nixpkgs=channel:nixos-23.05 \ +-I nixos-config=${config} diff --git a/config/nix/build.sh b/config/nix/build.sh deleted file mode 100755 index 001b47c..0000000 --- a/config/nix/build.sh +++ /dev/null @@ -1,5 +0,0 @@ -#/usr/bin/env sh -export NIXPKGS_ALLOW_UNFREE=1 -nix-build '' -A vm \ --I nixpkgs=channel:nixos-23.05 \ --I nixos-config=./testvm.nix diff --git a/config/nix/curacao.nix b/config/nix/curacao.nix index c1fcf5b..6dc088d 100644 --- a/config/nix/curacao.nix +++ b/config/nix/curacao.nix @@ -5,6 +5,6 @@ ./os/loader.nix ]; - networking.hostName = "curacao.geoffrey.frogeye.fr"; + networking.hostName = "curacao"; frogeye.extra = true; } diff --git a/config/nix/hm/common.nix b/config/nix/hm/common.nix index 2349987..661885e 100644 --- a/config/nix/hm/common.nix +++ b/config/nix/hm/common.nix @@ -407,7 +407,8 @@ in moreutils man visidata - nodePackages.insect + # nodePackages.insect # FIXME Don't install on aarch64 + # TODO Use whatever replaces insect translate-shell unzip unrar diff --git a/config/nix/hm/desktop.nix b/config/nix/hm/desktop.nix index b508335..9c6bd90 100644 --- a/config/nix/hm/desktop.nix +++ b/config/nix/hm/desktop.nix @@ -269,12 +269,13 @@ "d" = "exec ${autorandrmenu {title="Default profile"; option="--default"; builtin = true;}}, mode default"; } // return_bindings; "${mode_temp}" = { - "r" = "exec ${pkgs.sct}/bin/sct 1000"; - "d" = "exec ${pkgs.sct}/bin/sct 2000"; - "c" = "exec ${pkgs.sct}/bin/sct 4500"; - "o" = "exec ${pkgs.sct}/bin/sct"; - "a" = "exec ${pkgs.sct}/bin/sct 8000"; - "b" = "exec ${pkgs.sct}/bin/sct 10000"; + # "r" = "exec ${pkgs.sct}/bin/sct 1000"; + # "d" = "exec ${pkgs.sct}/bin/sct 2000"; + # "c" = "exec ${pkgs.sct}/bin/sct 4500"; + # "o" = "exec ${pkgs.sct}/bin/sct"; + # "a" = "exec ${pkgs.sct}/bin/sct 8000"; + # "b" = "exec ${pkgs.sct}/bin/sct 10000"; + # FIXME Not on aarch64 } // return_bindings; }; window = { diff --git a/config/nix/hm/dev.nix b/config/nix/hm/dev.nix index 6211e5a..2f1f4db 100644 --- a/config/nix/hm/dev.nix +++ b/config/nix/hm/dev.nix @@ -1,5 +1,4 @@ -{ pkgs, ... }: -{ +{ pkgs, ... }: { # TODO Separate in diffrent packages once the structure is finalized... # or connvert into per-directory requirements home.packages = with pkgs; [ @@ -29,7 +28,7 @@ # FPGA yosys verilog - ghdl + # ghdl # TODO Not on aarch64 gtkwave # TODO Display server only # Network diff --git a/config/nix/hm/vim.nix b/config/nix/hm/vim.nix index 76bcb44..22a4c94 100644 --- a/config/nix/hm/vim.nix +++ b/config/nix/hm/vim.nix @@ -15,13 +15,13 @@ let }; meta.homepage = "https://github.com/deris/vim-shot-f"; }; - quick-scope = pkgs.vimUtils.buildVimPluginFrom2Nix { + quick-scope = pkgs.vimUtils.buildVimPluginFrom2Nix rec { pname = "quick-scope"; version = "2.6.1"; src = pkgs.fetchFromGitHub { - owner = "deris"; + owner = "unblevable"; repo = "quick-scope"; - rev = "2.6.1"; + rev = "v${version}"; sha256 = "iAPvIs/lhW+w5kFTZKaY97D/kfCGtqKrJVFvZ8cHu+c="; }; meta.homepage = "https://github.com/unblevable/quick-scope"; diff --git a/config/nix/os/common.nix b/config/nix/os/common.nix index f6e64f6..eedc29d 100644 --- a/config/nix/os/common.nix +++ b/config/nix/os/common.nix @@ -1,5 +1,7 @@ { pkgs, lib, ... }: { + networking.domain = "geoffrey.frogeye.fr"; + boot.loader.efi.canTouchEfiVariables = true; time.timeZone = "Europe/Amsterdam"; diff --git a/config/nix/os/wireless.nix b/config/nix/os/wireless.nix index c583dcf..2c97fe9 100644 --- a/config/nix/os/wireless.nix +++ b/config/nix/os/wireless.nix @@ -4,7 +4,7 @@ # TODO This doesn't change anything, at least in the VM networking.wireless = { enable = true; - networks = builtins.fromJSON ./wireless/networks.json; # If this file doesn't exist, run ./wireless/import.py + networks = builtins.fromJSON (builtins.readFile ./wireless/networks.json); # If this file doesn't exist, run ./wireless/import.py extraConfig = '' country=NL ''; diff --git a/config/nix/pindakaas.nix b/config/nix/pindakaas.nix index 928ffd1..aef4544 100644 --- a/config/nix/pindakaas.nix +++ b/config/nix/pindakaas.nix @@ -3,8 +3,7 @@ imports = [ # - # ./os/loader.nix # Don't uncomment this before having put extra behind an option! + ./os/loader.nix ]; - nixpkgs.crossSystem.system = "aarch64-linux"; - # networking.hostName = "pindakaas.geoffrey.frogeye.fr"; + networking.hostName = "pindakaas"; } diff --git a/config/nix/testvm.nix b/config/nix/testvm.nix deleted file mode 100644 index e1dcc21..0000000 --- a/config/nix/testvm.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ ... }: -{ - imports = [ - ./os/loader.nix - ]; - - networking.hostName = "nixos"; - frogeye.extra = true; -}