mirror of
https://github.com/simplex-chat/haskell.nix.git
synced 2026-06-03 09:17:32 +00:00
05c0555400
This adds support for using nix flakes commands with hix. This is done by creating a hidden `.hix-flake` directory and passing the source in using `--override-input`. It also includes a `hix init` command to add a `flake.nix` and `nix/hix.nix` configuration file.
78 lines
2.5 KiB
Nix
78 lines
2.5 KiB
Nix
{ src
|
|
, userDefaults ? {}
|
|
, nixpkgs ? null
|
|
, nixpkgsPin ? null
|
|
, pkgs ? null
|
|
, checkMaterialization ? null
|
|
, compiler-nix-name ? null
|
|
, shell ? null
|
|
, ...}@commandArgs:
|
|
let
|
|
inherit ((lib.evalModules {
|
|
modules = [
|
|
(import ../../modules/project-common.nix)
|
|
(import ../../modules/stack-project.nix)
|
|
(import ../../modules/cabal-project.nix)
|
|
(import ../../modules/project.nix)
|
|
(import ../../modules/hix-project.nix)
|
|
projectDefaults
|
|
commandArgs'
|
|
{ _module.args.pkgs = {}; }
|
|
];
|
|
}).config) name;
|
|
inherit (import ./../.. {}) sources;
|
|
lib = import (sources.nixpkgs-unstable + "/lib");
|
|
commandArgs' =
|
|
builtins.listToAttrs (
|
|
builtins.concatMap (
|
|
name:
|
|
if commandArgs.${name} == null || name == "src" || name == "userDefaults" || name == "inNixShell"
|
|
then []
|
|
else [{ inherit name; value = commandArgs.${name}; }]
|
|
) (builtins.attrNames commandArgs));
|
|
defaultArgs = {
|
|
nixpkgsPin = "nixpkgs-unstable";
|
|
};
|
|
importDefaults = src:
|
|
if src == null || !(__pathExists src)
|
|
then {}
|
|
else import src;
|
|
userDefaults = importDefaults (commandArgs.userDefaults or null);
|
|
projectDefaults = importDefaults (toString (src.origSrcSubDir or src) + "/nix/hix.nix");
|
|
inherit ((lib.evalModules {
|
|
modules = [
|
|
(import ../../modules/project-common.nix)
|
|
(import ../../modules/stack-project.nix)
|
|
(import ../../modules/cabal-project.nix)
|
|
(import ../../modules/project.nix)
|
|
(import ../../modules/hix-project.nix)
|
|
userDefaults
|
|
projectDefaults
|
|
commandArgs'
|
|
({config, pkgs, ...}: {
|
|
haskellNix = import ./../.. { inherit checkMaterialization; };
|
|
nixpkgsPin = "nixpkgs-unstable";
|
|
nixpkgs = config.haskellNix.sources.${config.nixpkgsPin};
|
|
nixpkgsArgs = config.haskellNix.nixpkgsArgs // {
|
|
overlays = config.haskellNix.nixpkgsArgs.overlays ++ config.overlays;
|
|
};
|
|
_module.args.pkgs = import config.nixpkgs config.nixpkgsArgs;
|
|
project = pkgs.haskell-nix.project [
|
|
(import ../../modules/hix-project.nix)
|
|
userDefaults
|
|
projectDefaults
|
|
commandArgs'
|
|
({config, ...}: {
|
|
src =
|
|
if __pathExists (toString (src.origSrcSubDir or src) + "/.git")
|
|
then config.evalPackages.haskell-nix.haskellLib.cleanGit {
|
|
inherit src name;
|
|
}
|
|
else src;
|
|
})
|
|
];
|
|
})
|
|
];
|
|
}).config) project shell;
|
|
in project
|