Flake-enable the project

This commit is contained in:
Gabriella Gonzalez 2022-07-01 14:00:11 -07:00
parent 1881b0385b
commit 670846795d
6 changed files with 150 additions and 33 deletions

9
default.nix Normal file
View File

@ -0,0 +1,9 @@
(import (
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash; }
) {
src = ./.;
}).defaultNix

60
flake.lock generated Normal file
View File

@ -0,0 +1,60 @@
{
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1650374568,
"narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "b4a34015c698c7793d592d66adbab377907a2be8",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1653936696,
"narHash": "sha256-M6bJShji9AIDZ7Kh7CPwPBPb/T7RiVev2PAcOi4fxDQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "ce6aa13369b667ac2542593170993504932eb836",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "22.05",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-compat": "flake-compat",
"nixpkgs": "nixpkgs",
"utils": "utils"
}
},
"utils": {
"locked": {
"lastModified": 1656065134,
"narHash": "sha256-oc6E6ByIw3oJaIyc67maaFcnjYOz1mMcOtHxbEf9NwQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "bee6a7250dd1b01844a2de7e02e4df7d8a0a206c",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

68
flake.nix Normal file
View File

@ -0,0 +1,68 @@
{ inputs = {
nixpkgs.url = github:NixOS/nixpkgs/22.05;
utils.url = github:numtide/flake-utils;
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs = { nixpkgs, utils, ... }:
utils.lib.eachDefaultSystem (system:
let
overlay = pkgsNew: pkgsOld: {
haskellPackages = pkgsOld.haskellPackages.override (old: {
overrides =
pkgsNew.lib.fold pkgsNew.lib.composeExtensions (old.overrides or (_: _: { })) [
(pkgsNew.haskell.lib.packagesFromDirectory {
directory = ./nix;
})
(haskellPackagesNew: haskellPackagesOld: {
nix-serve-ng =
pkgsNew.haskell.lib.overrideCabal
haskellPackagesOld.nix-serve-ng
(old: {
executableSystemDepends = (old.executableSystemDepends or []) ++ [
pkgsNew.boost.dev
];
});
})
];
});
nix-serve-ng =
pkgsNew.haskell.lib.justStaticExecutables
pkgsNew.haskellPackages.nix-serve-ng;
};
pkgs = import nixpkgs {
config = { };
overlays = [ overlay ];
inherit system;
};
inherit (pkgs) nix-serve-ng;
in
rec {
packages.default = nix-serve-ng;
defaultPackage = packages.default;
apps.default = {
type = "app";
program = "${nix-serve-ng}/bin/nix-serve-ng";
};
defaultApp = apps.default;
devShells.default = pkgs.haskellPackages.nix-serve-ng.env;
devShell = devShells.default;
});
}

View File

@ -36,7 +36,7 @@ executable nix-serve-ng
cxx-sources: cbits/nix.cpp
cxx-options: -std=c++17
cpp-options: -std=c++17
build-depends: base < 5
, base16

View File

@ -1,7 +1,6 @@
{ mkDerivation, base, base16, base32, bytestring, charset
, http-types, managed, megaparsec, mtl, network, nix
, optparse-applicative, stdenv, vector, wai, wai-extra, warp
, warp-tls
, http-types, lib, managed, megaparsec, mtl, network, nix
, optparse-applicative, vector, wai, wai-extra, warp, warp-tls
}:
mkDerivation {
pname = "nix-serve-ng";
@ -15,5 +14,5 @@ mkDerivation {
];
executablePkgconfigDepends = [ nix ];
description = "A drop-in replacement for nix-serve that's faster and more stable";
license = stdenv.lib.licenses.asl20;
license = lib.licenses.asl20;
}

View File

@ -1,28 +1,9 @@
let
nixpkgs = builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/87d9c84817d7be81850c07e8f6a362b1dfc30feb.tar.gz";
sha256 = "0pcasnmdbs2lrsp4m8ww06xd7b318agfygi61qjsizb328nxhcqa";
};
overlay = pkgsNew: pkgsOld: {
haskellPackages = pkgsOld.haskellPackages.override (old: {
overrides =
pkgsNew.lib.composeExtensions
(old.overrides or (_: _: { }))
(haskellPackagesNew: haskellPackagesOld: {
nix-serve-ng =
pkgsNew.haskell.lib.overrideCabal
(haskellPackagesNew.callPackage ./nix/nix-serve-ng.nix { })
(old: {
executableSystemDepends = (old.executableSystemDepends or []) ++ [
pkgsNew.boost.dev
];
});
});
});
};
pkgs = import nixpkgs { config = { }; overlays = [ overlay ]; };
in
pkgs.haskellPackages.nix-serve-ng.env
(import (
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash; }
) {
src = ./.;
}).shellNix