Created
January 6, 2022 18:57
-
-
Save rehno-lindeque/8dcd4b7353e1cb1392f790934610dda9 to your computer and use it in GitHub Desktop.
Flake example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
inputs.flake-utils.url = "github:numtide/flake-utils"; | |
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | |
outputs = { self, nixpkgs, flake-utils }: | |
let | |
inherit (nixpkgs) lib; | |
# Add the flake's overlay to each of the pkgs | |
eachDefaultEnvironment = f: flake-utils.lib.eachDefaultSystem | |
( | |
system: | |
f { | |
inherit system; | |
pkgs = (import nixpkgs { inherit system; config.allowUnfree = true; }).extend self.overlay; | |
} | |
); | |
in | |
eachDefaultEnvironment | |
({ pkgs, system }: { | |
devShell = import ./shell.nix ({ inherit pkgs; } // self.packages."${system}"); | |
packages = rec { | |
py-hello = pkgs.python3Packages.py-hello; | |
}; | |
defaultPackage = (self.packages."${system}").py-hello; | |
}) // { | |
overlay = import ./overlay.nix self.inputs; | |
checks = self.packages; | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inputs: final: prev: | |
{ | |
# How it's done for python | |
python3 = prev.python3.override { | |
packageOverrides = pythonFinal: pythonSelf: { | |
py-hello = final.runCommand "py-hello" { } '' | |
${final.hello}/bin/hello | |
# presumably you need python for something here... | |
mkdir $out | |
''; | |
}; | |
}; | |
# How it's done for haskell | |
# haskell = prev.haskell // { | |
# packageOverrides = haskellFinal: haskellPrev: { | |
# lens = haskellFinal.lens_5_0_1; | |
# rel8 = haskellFinal.callCabal2nix "rel8" "${inputs.rel8}" { }; | |
# hs-opentelemetry-api = haskellFinal.callCabal2nixWithOptions "hs-opentelemetry" "${inputs.hs-opentelemetry}" "--subpath api" { }; | |
# thread-utils-context = haskellFinal.callCabal2nixWithOptions "thread-utils-context" "${inputs.thread-utils-context}" "" { }; | |
# thread-utils-finalizers = haskellFinal.callCabal2nixWithOptions "thread-utils-finalizers" "${inputs.thread-utils}" "--subpath thread-utils-finalizers" { }; | |
# }; | |
# }; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs | |
, py-hello | |
, ... | |
}: | |
pkgs.mkShell { | |
buildInputs = with pkgs; [ py-hello ]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment