Skip to content

Commit

Permalink
Correct darwin special channel more (#937)
Browse files Browse the repository at this point in the history
* Correct darwin special channel. Follow GH-924

* Partially revert dropping macos-13 CI in devshell
  • Loading branch information
kachick authored Nov 14, 2024
1 parent 61470e0 commit da6addc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci-nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
matrix:
os:
- ubuntu-24.04
- macos-13
runs-on: ${{ matrix.os }}
timeout-minutes: 30
steps:
Expand Down
45 changes: 30 additions & 15 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
}@inputs:
let
inherit (self) outputs;

# Candidates: https://github.com/NixOS/nixpkgs/blob/release-24.05/lib/systems/flake-systems.nix
forAllSystems = nixpkgs.lib.genAttrs (
nixpkgs.lib.intersectLists [
Expand All @@ -55,19 +56,28 @@
] nixpkgs.lib.systems.flakeExposed
);

mkApp = pkg: {
type = "app";
program = nixpkgs.lib.getExe pkg;
};
mkNixpkgs =
system: if (nixpkgs.lib.strings.hasSuffix "-darwin" system) then nixpkgs-darwin else nixpkgs;

mkHomeManager =
system:
if (nixpkgs.lib.strings.hasSuffix "-darwin" system) then
home-manager-darwin
else
home-manager-linux;

mkApp =
{ system, pkg }:
{
type = "app";
program = (mkNixpkgs system).lib.getExe pkg;
};

homemade-packages = forAllSystems (
system:
(
(if (nixpkgs.lib.strings.hasSuffix "-darwin" system) then nixpkgs-darwin else nixpkgs)
.legacyPackages.${system}.callPackage
./pkgs
{ edge-pkgs = edge-nixpkgs.legacyPackages.${system}; }
)
((mkNixpkgs system).legacyPackages.${system}.callPackage ./pkgs {
edge-pkgs = edge-nixpkgs.legacyPackages.${system};
})
);
in
{
Expand All @@ -76,12 +86,12 @@
# - https://github.com/NixOS/nixfmt/issues/129
# - https://github.com/NixOS/rfcs/pull/166
# - https://github.com/NixOS/nixfmt/blob/a81f922a2b362f347a6cbecff5fb14f3052bc25d/README.md#L19
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style);
formatter = forAllSystems (system: (mkNixpkgs system).legacyPackages.${system}.nixfmt-rfc-style);

devShells = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
pkgs = (mkNixpkgs system).legacyPackages.${system};
edge-pkgs = edge-nixpkgs.legacyPackages.${system};
homemade-pkgs = homemade-packages.${system};
in
Expand Down Expand Up @@ -145,7 +155,10 @@
(map
(name: {
inherit name;
value = mkApp homemade-packages.${system}.${name};
value = mkApp {
system = system;
pkg = homemade-packages.${system}.${name};
};
})
[
"bump_completions"
Expand Down Expand Up @@ -177,8 +190,10 @@
# https://github.com/NixOS/nix/issues/6448#issuecomment-1132855605
{
name = "home-manager";
# FIXME: Use home-manager-darwin in macOS
value = mkApp home-manager-linux.defaultPackage.${system};
value = mkApp {
system = system;
pkg = (mkHomeManager system).defaultPackage.${system};
};
}
]
)
Expand Down

0 comments on commit da6addc

Please sign in to comment.