Created
November 28, 2022 15:45
-
-
Save gotcha/bee65ed2103e9d7f6b8af236bff09590 to your computer and use it in GitHub Desktop.
This file contains 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 = { | |
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix"; | |
pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs"; | |
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | |
devenv.url = "github:cachix/devenv?dir=src/modules"; | |
} // (if builtins.pathExists ./.devenv/devenv.json | |
then (builtins.fromJSON (builtins.readFile ./.devenv/devenv.json)).inputs | |
else {}); | |
outputs = { nixpkgs, ... }@inputs: | |
let | |
pkgs = import nixpkgs { system = "x86_64-darwin"; }; | |
lib = pkgs.lib; | |
devenv = if builtins.pathExists ./.devenv/devenv.json | |
then builtins.fromJSON (builtins.readFile ./.devenv/devenv.json) | |
else {}; | |
toModule = path: | |
if lib.hasPrefix "./" path | |
then ./. + (builtins.substring 1 255 path) + "/devenv.nix" | |
else if lib.hasPrefix "../" path | |
then throw "devenv: ../ is not supported for imports" | |
else let | |
paths = lib.splitString "/" path; | |
name = builtins.head paths; | |
input = inputs.${name} or (throw "Unknown input ${name}"); | |
subpath = "/${lib.concatStringsSep "/" (builtins.tail paths)}"; | |
devenvpath = "${input}/" + subpath + "/devenv.nix"; | |
in if (!devenv.inputs.${name}.flake) && builtins.pathExists devenvpath | |
then devenvpath | |
else throw (devenvpath + " file does not exist for input ${name}."); | |
project = pkgs.lib.evalModules { | |
specialArgs = inputs // { inherit pkgs; }; | |
modules = [ | |
(inputs.devenv.modules + /top-level.nix) | |
] ++ (map toModule (devenv.imports or [])) ++ [ | |
./devenv.nix | |
(devenv.devenv or {}) | |
(if builtins.pathExists ./devenv.local.nix then ./devenv.local.nix else {}) | |
]; | |
}; | |
config = project.config; | |
in { | |
packages."x86_64-darwin" = { | |
ci = pkgs.runCommand "ci" {} ("ls " + toString config.ci + " && touch $out"); | |
procfile = config.procfile; | |
procfileEnv = config.procfileEnv; | |
}; | |
devShell."x86_64-darwin" = config.shell; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment