Skip to content

Commit

Permalink
Make most packages refer darwin special channel if run on macOS (#924)
Browse files Browse the repository at this point in the history
* Make most packages refers darwin special channel if run on macOS

Fixes GH-910

* flake.lock: Update

Flake lock file updates:

• Updated input 'edge-nixpkgs':
    'github:NixOS/nixpkgs/4aa36568d413aca0ea84a1684d2d46f55dbabad7?narHash=sha256-Zwl8YgTVJTEum%2BL%2B0zVAWvXAGbWAuXHax3KzuejaDyo%3D' (2024-11-05)
  → 'github:NixOS/nixpkgs/76612b17c0ce71689921ca12d9ffdc9c23ce40b2?narHash=sha256-IigrKK3vYRpUu%2BHEjPL/phrfh7Ox881er1UEsZvw9Q4%3D' (2024-11-09)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/dba414932936fde69f0606b4f1d87c5bc0003ede?narHash=sha256-mwrFF0vElHJP8X3pFCByJR365Q2463ATp2qGIrDUdlE%3D' (2024-11-06)
  → 'github:NixOS/nixpkgs/83fb6c028368e465cd19bb127b86f971a5e41ebc?narHash=sha256-rz30HrFYCHiWEBCKHMffHbMdWJ35hEkcRVU0h7ms3x0%3D' (2024-11-07)

* Fix to branch nix channel in homemade packages

* Enable magic-nix-cache-action in home-manager CI only on darwin

* Revert "Enable magic-nix-cache-action in home-manager CI only on darwin"

This reverts commit f14cdff.

* Sync same channel in home-manager

* Remove garbage code in GH-796

* Enable decadent  magic nix cache only in macos-13

* fix? to specify intel mac

* Enable decadent magic nix cache only in macos-13 also in ci-nix

* Don't maintain this repository on darwin, use lima

To avoid rate limit

* Drop macos-15 runner in CI matrix

I just experienced with arch problems, not for the OS version problems in home-manager

And I want to reduce macos related code with GH-911

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
kachick and github-actions[bot] authored Nov 11, 2024
1 parent fb5f31a commit 9cf737b
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 58 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ jobs:
matrix:
os:
- ubuntu-24.04
- macos-15 # Apple Silicon. Doesn't match for my Intel Mac, but preferring with the speed.
- windows-latest
runs-on: ${{ matrix.os }}
steps:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/ci-home.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: DeterminateSystems/nix-installer-action@v14
# Don't use DeterminateSystems/magic-nix-cache-action in this workflow until https://github.com/DeterminateSystems/magic-nix-cache-action/issues/26 is supported
# Don't use DeterminateSystems/magic-nix-cache-action for Linux until https://github.com/DeterminateSystems/magic-nix-cache-action/issues/26 is supported
- uses: DeterminateSystems/magic-nix-cache-action@v8
# Always slow. Especially since GH-924
if: runner.os == 'macOS' && runner.arch == 'X64'
- name: Print some dotfiles overviews
run: |
</etc/nix/nix.conf
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/ci-nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ jobs:
matrix:
os:
- ubuntu-24.04
- macos-15 # Apple Silicon. Doesn't match for my Intel Mac, but preferring with the speed.
runs-on: ${{ matrix.os }}
timeout-minutes: 30
steps:
Expand All @@ -37,7 +36,6 @@ jobs:
run: |
</etc/nix/nix.conf
ls -alh ~
- uses: DeterminateSystems/magic-nix-cache-action@v8
- run: nix develop --command echo 'This step should be done before any other "nix develop" steps because of measuring Nix build time'
- run: nix flake show
- run: nix flake check
Expand Down
2 changes: 0 additions & 2 deletions cmd/gen_matrix/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ func main() {
// https://github.com/actions/runner-images/issues/9741#issuecomment-2075259811
Os: []string{
"ubuntu-24.04",
// Apple Silicon. Doesn't match for my Intel Mac, but preferring with the speed.
"macos-15",
},
}

Expand Down
67 changes: 53 additions & 14 deletions flake.lock

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

64 changes: 27 additions & 37 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
# - https://discourse.nixos.org/t/differences-between-nix-channels/13998
# How to update the revision
# - `nix flake update --commit-lock-file` # https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake-update.html
# TODO: Use nixpkgs-24.05-darwin only in macOS. See GH-910
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
edge-nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
edge-nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; # Unfit for darwin, might be broken. See https://github.com/NixOS/nixpkgs/issues/107466
nixpkgs-darwin.url = "github:NixOS/nixpkgs/nixpkgs-24.05-darwin";
# https://github.com/nix-community/home-manager/blob/release-24.05/docs/manual/nix-flakes.md
home-manager = {
home-manager-linux = {
url = "github:nix-community/home-manager/release-24.05";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager-darwin = {
url = "github:nix-community/home-manager/release-24.05";
inputs.nixpkgs.follows = "nixpkgs-darwin";
};
nixos-wsl = {
url = "github:nix-community/NixOS-WSL/2405.5.4";
# https://github.com/nix-community/NixOS-WSL/blob/5a965cb108fb1f30b29a26dbc29b473f49e80b41/flake.nix#L5
Expand All @@ -36,7 +40,9 @@
self,
nixpkgs,
edge-nixpkgs,
home-manager,
nixpkgs-darwin,
home-manager-linux,
home-manager-darwin,
...
}@inputs:
let
Expand All @@ -51,9 +57,12 @@

homemade-packages = forAllSystems (
system:
(nixpkgs.legacyPackages.${system}.callPackage ./pkgs {
edge-pkgs = edge-nixpkgs.legacyPackages.${system};
})
(
(if (nixpkgs.lib.strings.hasSuffix "-darwin" system) then nixpkgs-darwin else nixpkgs)
.legacyPackages.${system}.callPackage
./pkgs
{ edge-pkgs = edge-nixpkgs.legacyPackages.${system}; }
)
);
in
{
Expand Down Expand Up @@ -164,7 +173,8 @@
# https://github.com/NixOS/nix/issues/6448#issuecomment-1132855605
{
name = "home-manager";
value = mkApp home-manager.defaultPackage.${system};
# FIXME: Use home-manager-darwin in macOS
value = mkApp home-manager-linux.defaultPackage.${system};
}
]
)
Expand Down Expand Up @@ -209,23 +219,15 @@
};

x86-macOS = {
pkgs = nixpkgs.legacyPackages.x86_64-darwin;
pkgs = nixpkgs-darwin.legacyPackages.x86_64-darwin;
extraSpecialArgs = {
homemade-pkgs = homemade-packages.x86_64-darwin;
edge-pkgs = edge-nixpkgs.legacyPackages.x86_64-darwin;
};
};

aarch64-macOS = {
pkgs = nixpkgs.legacyPackages.aarch64-darwin;
extraSpecialArgs = {
homemade-pkgs = homemade-packages.aarch64-darwin;
edge-pkgs = edge-nixpkgs.legacyPackages.aarch64-darwin;
};
};
in
{
"kachick@desktop" = home-manager.lib.homeManagerConfiguration (
"kachick@desktop" = home-manager-linux.lib.homeManagerConfiguration (
x86-Linux
// {
modules = [
Expand All @@ -236,7 +238,7 @@
}
);

"kachick@wsl-ubuntu" = home-manager.lib.homeManagerConfiguration (
"kachick@wsl-ubuntu" = home-manager-linux.lib.homeManagerConfiguration (
x86-Linux
// {
modules = [
Expand All @@ -246,7 +248,7 @@
}
);

"nixos@wsl-nixos" = home-manager.lib.homeManagerConfiguration (
"nixos@wsl-nixos" = home-manager-linux.lib.homeManagerConfiguration (
x86-Linux
// {
modules = [
Expand All @@ -257,11 +259,11 @@
}
);

"kachick@macbook" = home-manager.lib.homeManagerConfiguration (
"kachick@macbook" = home-manager-darwin.lib.homeManagerConfiguration (
x86-macOS // { modules = [ ./home-manager/kachick.nix ]; }
);

"kachick@lima" = home-manager.lib.homeManagerConfiguration (
"kachick@lima" = home-manager-darwin.lib.homeManagerConfiguration (
x86-Linux
// {
modules = [
Expand All @@ -271,7 +273,7 @@
}
);

"[email protected]" = home-manager.lib.homeManagerConfiguration (
"[email protected]" = home-manager-linux.lib.homeManagerConfiguration (
x86-Linux
// {
# Prefer "kachick" over "common" only here.
Expand All @@ -284,7 +286,7 @@
}
);

"github-actions@macos-13" = home-manager.lib.homeManagerConfiguration (
"github-actions@macos-13" = home-manager-darwin.lib.homeManagerConfiguration (
x86-macOS
// {
# Prefer "kachick" over "common" only here.
Expand All @@ -296,19 +298,7 @@
}
);

"github-actions@macos-15" = home-manager.lib.homeManagerConfiguration (
aarch64-macOS
// {
# Prefer "kachick" over "common" only here.
# Using values as much as possible as actual values to create a robust CI
modules = [
./home-manager/kachick.nix
{ home.username = "runner"; }
];
}
);

"user@linux-cli" = home-manager.lib.homeManagerConfiguration (
"user@linux-cli" = home-manager-linux.lib.homeManagerConfiguration (
x86-Linux
// {
modules = [
Expand Down
1 change: 0 additions & 1 deletion nixos/desktop/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
(import ./font.nix { inherit pkgs homemade-pkgs; })
inputs.xremap-flake.nixosModules.default
./xremap.nix
inputs.home-manager.nixosModules.home-manager
];

# Define a user account. Don't forget to set a password with ‘passwd’.
Expand Down

0 comments on commit 9cf737b

Please sign in to comment.