Skip to content

Commit

Permalink
Merge pull request #6624 from NixOS/new-flake-style
Browse files Browse the repository at this point in the history
flake.nix: Convert to new naming convention
  • Loading branch information
thufschmitt committed Jun 8, 2022
2 parents e88892d + faf80fa commit 694b120
Showing 1 changed file with 36 additions and 36 deletions.
72 changes: 36 additions & 36 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
)
);

forAllStdenvs = stdenvs: f: nixpkgs.lib.genAttrs stdenvs (stdenv: f stdenv);
forAllStdenvs = f: nixpkgs.lib.genAttrs stdenvs (stdenv: f stdenv);

# Memoize nixpkgs for different platforms for efficiency.
nixpkgsFor =
Expand Down Expand Up @@ -404,7 +404,7 @@

# A Nixpkgs overlay that overrides the 'nix' and
# 'nix.perl-bindings' packages.
overlay = overlayFor (p: p.stdenv);
overlays.default = overlayFor (p: p.stdenv);

hydraJobs = {

Expand All @@ -429,7 +429,7 @@
value = let
nixpkgsCross = import nixpkgs {
inherit system crossSystem;
overlays = [ self.overlay ];
overlays = [ self.overlays.default ];
};
in binaryTarball nixpkgsFor.${system} self.packages.${system}."nix-${crossSystem}" nixpkgsCross;
}) crossSystems));
Expand Down Expand Up @@ -475,39 +475,39 @@
tests.remoteBuilds = import ./tests/remote-builds.nix {
system = "x86_64-linux";
inherit nixpkgs;
inherit (self) overlay;
overlay = self.overlays.default;
};

tests.nix-copy-closure = import ./tests/nix-copy-closure.nix {
system = "x86_64-linux";
inherit nixpkgs;
inherit (self) overlay;
overlay = self.overlays.default;
};

tests.nssPreload = (import ./tests/nss-preload.nix rec {
system = "x86_64-linux";
inherit nixpkgs;
inherit (self) overlay;
overlay = self.overlays.default;
});

tests.githubFlakes = (import ./tests/github-flakes.nix rec {
system = "x86_64-linux";
inherit nixpkgs;
inherit (self) overlay;
overlay = self.overlays.default;
});

tests.sourcehutFlakes = (import ./tests/sourcehut-flakes.nix rec {
system = "x86_64-linux";
inherit nixpkgs;
inherit (self) overlay;
overlay = self.overlays.default;
});

tests.setuid = nixpkgs.lib.genAttrs
["i686-linux" "x86_64-linux"]
(system:
import ./tests/setuid.nix rec {
inherit nixpkgs system;
inherit (self) overlay;
overlay = self.overlays.default;
});

# Make sure that nix-env still produces the exact same result
Expand Down Expand Up @@ -552,8 +552,9 @@
dockerImage = self.hydraJobs.dockerImage.${system};
});

packages = forAllSystems (system: {
packages = forAllSystems (system: rec {
inherit (nixpkgsFor.${system}) nix;
default = nix;
} // (nixpkgs.lib.optionalAttrs (builtins.elem system linux64BitSystems) {
nix-static = let
nixpkgs = nixpkgsFor.${system}.pkgsStatic;
Expand Down Expand Up @@ -616,7 +617,7 @@
value = let
nixpkgsCross = import nixpkgs {
inherit system crossSystem;
overlays = [ self.overlay ];
overlays = [ self.overlays.default ];
};
in with commonDeps nixpkgsCross; nixpkgsCross.stdenv.mkDerivation {
name = "nix-${version}";
Expand Down Expand Up @@ -658,38 +659,37 @@
nixpkgsFor.${system}."${stdenvName}Packages".nix
) stdenvs)));

defaultPackage = forAllSystems (system: self.packages.${system}.nix);

devShell = forAllSystems (system: self.devShells.${system}.stdenvPackages);

devShells = forAllSystemsAndStdenvs (system: stdenv:
with nixpkgsFor.${system};
with commonDeps pkgs;

nixpkgsFor.${system}.${stdenv}.mkDerivation {
name = "nix";
devShells = forAllSystems (system:
forAllStdenvs (stdenv:
with nixpkgsFor.${system};
with commonDeps pkgs;
nixpkgsFor.${system}.${stdenv}.mkDerivation {
name = "nix";

outputs = [ "out" "dev" "doc" ];
outputs = [ "out" "dev" "doc" ];

nativeBuildInputs = nativeBuildDeps;
buildInputs = buildDeps ++ propagatedDeps ++ awsDeps;
nativeBuildInputs = nativeBuildDeps;
buildInputs = buildDeps ++ propagatedDeps ++ awsDeps;

inherit configureFlags;
inherit configureFlags;

enableParallelBuilding = true;
enableParallelBuilding = true;

installFlags = "sysconfdir=$(out)/etc";
installFlags = "sysconfdir=$(out)/etc";

shellHook =
''
PATH=$prefix/bin:$PATH
unset PYTHONPATH
export MANPATH=$out/share/man:$MANPATH
shellHook =
''
PATH=$prefix/bin:$PATH
unset PYTHONPATH
export MANPATH=$out/share/man:$MANPATH
# Make bash completion work.
XDG_DATA_DIRS+=:$out/share
'';
});
# Make bash completion work.
XDG_DATA_DIRS+=:$out/share
'';
}
)
// { default = self.devShells.${system}.stdenv; }
);

};
}

0 comments on commit 694b120

Please sign in to comment.