diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 79c783f..69b78f9 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -65,7 +65,7 @@ jobs: export AWS_SHARED_CREDENTIALS_FILE=/Users/Shared/.aws-credentials # Exit if the out path is empty - test -z "$OUT_PATHS" && exit + test -z "$OUT_PATHS" && ( echo "OUT_PATHS is empty; exit) # Without OUT_PATHS things kind of work most of the time. # Thus, let just or true and exit, so that if it works, it works, if it doesn't it just ignore @@ -80,14 +80,24 @@ jobs: - name: Configure Nix to use my cache run: | - cat <> $GITHUB_ENV + #EOF + + #sudo launchctl kickstart -k system/org.nixos.nix-daemon - sudo launchctl kickstart -k system/org.nixos.nix-daemon + - name: Switch to the ci system + run: | + export AWS_SHARED_CREDENTIALS_FILE=/Users/Shared/.aws-credentials + nix run nix-darwin/master#darwin-rebuild -- build --flake .#ci + mkdir -p /Users/Shared/nix/ + sudo mv /etc/nix/nix.conf /Users/Shared/nix/ + sudo --preserve-env=NIX_CONFIG nix run nix-darwin/master#darwin-rebuild -- switch --flake .#ci - name: Build my devShell run: | diff --git a/Makefile b/Makefile index 759f19a..64b2089 100644 --- a/Makefile +++ b/Makefile @@ -30,4 +30,4 @@ rebuild: darwin-rebuild build --flake .#pro-m2 switch: - darwin-rebuild switch --flake .#pro-m2 + sudo darwin-rebuild switch --flake .#pro-m2 diff --git a/flake.lock b/flake.lock index f9bad2a..7ab66a6 100644 --- a/flake.lock +++ b/flake.lock @@ -37,11 +37,11 @@ ] }, "locked": { - "lastModified": 1744478979, - "narHash": "sha256-dyN+teG9G82G+m+PX/aSAagkC+vUv0SgUw3XkPhQodQ=", + "lastModified": 1749194393, + "narHash": "sha256-vt6hM9DNywnXXuW1qPDLzECmbDcmxhh58wpb0EEQjAo=", "owner": "nix-darwin", "repo": "nix-darwin", - "rev": "43975d782b418ebf4969e9ccba82466728c2851b", + "rev": "19346808c445f23b08652971be198b9df6c33edc", "type": "github" }, "original": { @@ -267,6 +267,27 @@ "type": "gitlab" } }, + "nix-rosetta-builder": { + "inputs": { + "nixos-generators": "nixos-generators", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1745249216, + "narHash": "sha256-bNuaIdGrs8LfintWymo9KQTILwVxsw5T6zdfxZY6K0g=", + "owner": "cpick", + "repo": "nix-rosetta-builder", + "rev": "5cf6aa1f3f2fbb70443d33b5ef7779b7c7063392", + "type": "github" + }, + "original": { + "owner": "cpick", + "repo": "nix-rosetta-builder", + "type": "github" + } + }, "nixago": { "inputs": { "flake-utils": "flake-utils_2", @@ -274,11 +295,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1714086354, - "narHash": "sha256-yKVQMxL9p7zCWUhnGhDzRVT8sDgHoI3V595lBK0C2YA=", + "lastModified": 1746801636, + "narHash": "sha256-dlcKfIXp/eqFHzFm+DzseXAWWlpVwyk9cTvCKGtVKkw=", "owner": "nix-community", "repo": "nixago", - "rev": "5133633e9fe6b144c8e00e3b212cdbd5a173b63d", + "rev": "8cc33f973ab3a891d8a41391e73ef451a783960b", "type": "github" }, "original": { @@ -389,13 +410,50 @@ "type": "github" } }, + "nixlib": { + "locked": { + "lastModified": 1736643958, + "narHash": "sha256-tmpqTSWVRJVhpvfSN9KXBvKEXplrwKnSZNAoNPf/S/s=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "1418bc28a52126761c02dd3d89b2d8ca0f521181", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixos-generators": { + "inputs": { + "nixlib": "nixlib", + "nixpkgs": [ + "nix-rosetta-builder", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1737057290, + "narHash": "sha256-3Pe0yKlCc7EOeq1X/aJVDH0CtNL+tIBm49vpepwL1MQ=", + "owner": "nix-community", + "repo": "nixos-generators", + "rev": "d002ce9b6e7eb467cd1c6bb9aef9c35d191b5453", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixos-generators", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1744502386, - "narHash": "sha256-QAd1L37eU7ktL2WeLLLTmI6P9moz9+a/ONO8qNBYJgM=", + "lastModified": 1749213349, + "narHash": "sha256-UAaWOyQhdp7nXzsbmLVC67fo+QetzoTm9hsPf9X3yr4=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "f6db44a8daa59c40ae41ba6e5823ec77fe0d2124", + "rev": "a4ff0e3c64846abea89662bfbacf037ef4b34207", "type": "github" }, "original": { @@ -499,6 +557,7 @@ "inputs": { "darwin": "darwin", "m": "m", + "nix-rosetta-builder": "nix-rosetta-builder", "nixpkgs": "nixpkgs", "std": "std" } diff --git a/flake.nix b/flake.nix index 0a43c04..e2ddac2 100644 --- a/flake.nix +++ b/flake.nix @@ -24,10 +24,10 @@ inputs.nixpkgs.follows = "nixpkgs"; }; - #nix-rosetta-builder = { - # url = "github:cpick/nix-rosetta-builder"; - # inputs.nixpkgs.follows = "nixpkgs"; - #}; + nix-rosetta-builder = { + url = "github:cpick/nix-rosetta-builder"; + inputs.nixpkgs.follows = "nixpkgs"; + }; # TODO: help bring tezos via nix on macOS #tezos.url = "github:serokell/tezos-packaging"; }; diff --git a/src/hosts/darwin/pro.nix b/src/hosts/darwin/pro.nix index 6c16647..34fff5a 100644 --- a/src/hosts/darwin/pro.nix +++ b/src/hosts/darwin/pro.nix @@ -23,6 +23,8 @@ in { environment.variables.LC_ALL = "en_US.UTF-8"; # TODO: date format, local money? + system.primaryUser = "m"; + # Show all files including hidden system.defaults.NSGlobalDomain.AppleShowAllFiles = false; # Show all extensions in filename @@ -70,7 +72,7 @@ in { # Change default view to list view system.defaults.finder.FXPreferredViewStyle = "Nlsv"; # Don't show any icons on the desktop - system.defaults.finder.CreateDesktop = false; + system.defaults.finder.CreateDesktop = true; # Don't warn when changing the extension of a file system.defaults.finder.FXEnableExtensionChangeWarning = false; @@ -86,6 +88,9 @@ in { # Allow two finger click for right click on the trackpad system.defaults.trackpad.TrackpadRightClick = true; + # Calendar.app defaults + system.defaults.iCal."TimeZone support enabled" = true; + # Custom user preferences system.defaults.CustomUserPreferences = { # GPG tools @@ -176,6 +181,7 @@ in { "kodi" "little-snitch" "livebook" + "lm-studio" "logseq" "loopback" #"love" @@ -212,7 +218,7 @@ in { ]; brews = [ - "ext4fuse" + #"ext4fuse" "imageoptim-cli" "pinentry-mac" #"siril" @@ -321,6 +327,11 @@ in { nix = { enable = true; + linux-builder = { + enable = true; + config.virtualisation.cores = 4; + }; + gc = { interval = { Hour = 23; diff --git a/src/hosts/modules/nix-macos.nix b/src/hosts/modules/nix-macos.nix new file mode 100644 index 0000000..9fda030 --- /dev/null +++ b/src/hosts/modules/nix-macos.nix @@ -0,0 +1,62 @@ +{ + config, + pkgs, + lib, + ... +}: { + # Log access to the linux builder + launchd.daemons.linux-builder = { + serviceConfig = { + StandardOutPath = "/var/log/darwin-builder.log"; + StandardErrorPath = "/var/log/darwin-builder.log"; + }; + }; + + nix = { + enable = true; + + linux-builder = { + enable = true; + systems = ["aarch64-linux"]; + #config = { + # virtualisation.cores = 4; + # services.openssh.enable = true; + #}; + }; + + gc = { + interval = { + Hour = 23; + Minute = 55; + }; + options = "--delete-older-than 14d"; + }; + + settings = { + substituters = ["s3://mdots?endpoint=https://s3.fr-par.scw.cloud/®ion=fr-par"]; + trusted-public-keys = ["mdots:h40b7TWhz9PqO04aqOAiAEEdulJ2Q9oJ3MxXQCgQVvs="]; + trusted-users = ["m"]; + }; + + extraOptions = '' + experimental-features = nix-command flakes + keep-outputs = true + keep-derivations = true + keep-failed = false + keep-going = true + builders-use-substitutes = true + ''; + + distributedBuilds = true; + + buildMachines = [ + { + hostName = "purism"; + system = "x86_64-linux"; + protocol = "ssh-ng"; + maxJobs = 4; + supportedFeatures = ["kvm"]; + } + ]; + }; +} diff --git a/src/hosts/packages.nix b/src/hosts/packages.nix index ee57961..e0fe378 100644 --- a/src/hosts/packages.nix +++ b/src/hosts/packages.nix @@ -2,15 +2,33 @@ inputs, cell, }: let - inherit (inputs) nixpkgs darwin m; + inherit (inputs) nixpkgs darwin m nix-rosetta-builder; in { + # A CI config to start the linux-builder + darwinConfigurations."ci" = darwin.lib.darwinSystem { + system = "aarch64-darwin"; + modules = [ + {system.stateVersion = 6;} + ./modules/nix-macos.nix + ]; + }; + darwinConfigurations."pro-m2" = darwin.lib.darwinSystem { #default = darwin.lib.darwinSystem { # you can have multiple darwinConfigurations per flake, one per hostname specialArgs = {inherit m;}; system = "aarch64-darwin"; modules = [ + ./modules/nix-macos.nix ./darwin/pro.nix + nix-rosetta-builder.darwinModules.default + { + # see available options in module.nix's options.nix-rosetta-builder` + nix-rosetta-builder = { + enable = true; + onDemand = true; + }; + } ]; }; }