Support Lix 2.92 (#42)
* Support Lix 2.92 nix-serve-ng can now build against lix by passing -f lix to cabal the flake now also exports the `lix-serve-ng` package for a version that is built against lix * add back configureFlags, lost in rebase
This commit is contained in:
parent
101b4a552f
commit
d1b8a9a02f
@ -96,6 +96,12 @@ in
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Lix compatability
|
||||||
|
|
||||||
|
The default `nix-serve-ng` should work on top of lix, but if you want to build
|
||||||
|
it against lix for development or to remove the default nix dependency, you can
|
||||||
|
pass `-f lix` to cabal or use the `lix-serve-ng` package from the flake.
|
||||||
|
|
||||||
## Motivation
|
## Motivation
|
||||||
|
|
||||||
Our requirements for this project were:
|
Our requirements for this project were:
|
||||||
|
@ -1,9 +1,15 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
#include <nix/store/store-api.hh>
|
#ifndef LIX
|
||||||
#include <nix/store/log-store.hh>
|
#include <nix/store/store-api.hh>
|
||||||
#include <nix/main/shared.hh>
|
#include <nix/store/log-store.hh>
|
||||||
|
#include <nix/main/shared.hh>
|
||||||
|
#else
|
||||||
|
#include <lix/libstore/store-api.hh>
|
||||||
|
#include <lix/libstore/log-store.hh>
|
||||||
|
#include <lix/libmain/shared.hh>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "nix.hh"
|
#include "nix.hh"
|
||||||
|
|
||||||
@ -17,7 +23,11 @@ static ref<Store> getStore()
|
|||||||
static std::shared_ptr<Store> _store;
|
static std::shared_ptr<Store> _store;
|
||||||
|
|
||||||
if (!_store) {
|
if (!_store) {
|
||||||
|
#ifndef LIX
|
||||||
initLibStore(true);
|
initLibStore(true);
|
||||||
|
#else
|
||||||
|
initNix();
|
||||||
|
#endif
|
||||||
|
|
||||||
_store = openStore();
|
_store = openStore();
|
||||||
}
|
}
|
||||||
@ -122,7 +132,11 @@ void queryPathInfo
|
|||||||
output->deriver = emptyString;
|
output->deriver = emptyString;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef LIX
|
||||||
copyString(validPathInfo->narHash.to_string(nix::HashFormat::Nix32, true), &output->narHash);
|
copyString(validPathInfo->narHash.to_string(nix::HashFormat::Nix32, true), &output->narHash);
|
||||||
|
#else
|
||||||
|
copyString(validPathInfo->narHash.to_string(nix::Base::Base32, true), &output->narHash);
|
||||||
|
#endif
|
||||||
|
|
||||||
output->narSize = validPathInfo->narSize;
|
output->narSize = validPathInfo->narSize;
|
||||||
|
|
||||||
@ -185,7 +199,11 @@ bool dumpPath
|
|||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
#ifndef LIX
|
||||||
store->narFromPath(storePath.value(), sink);
|
store->narFromPath(storePath.value(), sink);
|
||||||
|
#else
|
||||||
|
sink << store->narFromPath(storePath.value());
|
||||||
|
#endif
|
||||||
} catch (const std::runtime_error & e) {
|
} catch (const std::runtime_error & e) {
|
||||||
// Intentionally do nothing. We're only using the exception as a
|
// Intentionally do nothing. We're only using the exception as a
|
||||||
// short-circuiting mechanism.
|
// short-circuiting mechanism.
|
||||||
|
105
flake.lock
generated
105
flake.lock
generated
@ -16,7 +16,93 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"flake-compat_2": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1696426674,
|
||||||
|
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"lix": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-compat": "flake-compat_2",
|
||||||
|
"nix2container": "nix2container",
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"nixpkgs-regression": "nixpkgs-regression",
|
||||||
|
"pre-commit-hooks": "pre-commit-hooks"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1737234286,
|
||||||
|
"narHash": "sha256-CCKIAE84dzkrnlxJCKFyffAxP3yfsOAbdvydUGqq24g=",
|
||||||
|
"rev": "2837da71ec1588c1187d2e554719b15904a46c8b",
|
||||||
|
"revCount": 16631,
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://git.lix.systems/lix-project/lix"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"rev": "2837da71ec1588c1187d2e554719b15904a46c8b",
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://git.lix.systems/lix-project/lix"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nix2container": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1724996935,
|
||||||
|
"narHash": "sha256-njRK9vvZ1JJsP8oV2OgkBrpJhgQezI03S7gzskCcHos=",
|
||||||
|
"owner": "nlewo",
|
||||||
|
"repo": "nix2container",
|
||||||
|
"rev": "fa6bb0a1159f55d071ba99331355955ae30b3401",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nlewo",
|
||||||
|
"repo": "nix2container",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1733348545,
|
||||||
|
"narHash": "sha256-b4JrUmqT0vFNx42aEN9LTWOHomkTKL/ayLopflVf81U=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "9ecb50d2fae8680be74c08bb0a995c5383747f89",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-24.11-small",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs-regression": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1643052045,
|
||||||
|
"narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1744174375,
|
"lastModified": 1744174375,
|
||||||
"narHash": "sha256-oxI9TLgnQbQ/WL0tIwVSIooLbXq4PW1QUhf5aQmXFgk=",
|
"narHash": "sha256-oxI9TLgnQbQ/WL0tIwVSIooLbXq4PW1QUhf5aQmXFgk=",
|
||||||
@ -32,10 +118,27 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"pre-commit-hooks": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1733318908,
|
||||||
|
"narHash": "sha256-SVQVsbafSM1dJ4fpgyBqLZ+Lft+jcQuMtEL3lQWx2Sk=",
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "git-hooks.nix",
|
||||||
|
"rev": "6f4e2a2112050951a314d2733a994fbab94864c6",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "git-hooks.nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-compat": "flake-compat",
|
"flake-compat": "flake-compat",
|
||||||
"nixpkgs": "nixpkgs",
|
"lix": "lix",
|
||||||
|
"nixpkgs": "nixpkgs_2",
|
||||||
"utils": "utils"
|
"utils": "utils"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
47
flake.nix
47
flake.nix
@ -3,6 +3,8 @@
|
|||||||
# Temporary, until Nixpkgs master has Nix 2.28
|
# Temporary, until Nixpkgs master has Nix 2.28
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/master";
|
nixpkgs.url = "github:NixOS/nixpkgs/master";
|
||||||
|
|
||||||
|
lix.url = "git+https://git.lix.systems/lix-project/lix?rev=2837da71ec1588c1187d2e554719b15904a46c8b";
|
||||||
|
|
||||||
utils.url = "github:numtide/flake-utils";
|
utils.url = "github:numtide/flake-utils";
|
||||||
|
|
||||||
flake-compat = {
|
flake-compat = {
|
||||||
@ -12,11 +14,13 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
outputs =
|
outputs =
|
||||||
{ nixpkgs, utils, ... }:
|
{ nixpkgs, lix, utils, ... }:
|
||||||
let
|
let
|
||||||
compiler = "ghc94";
|
compiler = "ghc94";
|
||||||
|
|
||||||
overlay = final: prev: {
|
overlay = final: prev: {
|
||||||
|
lix = lix.packages.${final.system}.default;
|
||||||
|
|
||||||
cabal2nix-unwrapped =
|
cabal2nix-unwrapped =
|
||||||
final.haskell.lib.justStaticExecutables
|
final.haskell.lib.justStaticExecutables
|
||||||
final.haskell.packages."${compiler}".cabal2nix;
|
final.haskell.packages."${compiler}".cabal2nix;
|
||||||
@ -27,6 +31,7 @@
|
|||||||
overrides = final.lib.fold final.lib.composeExtensions (old.overrides or (_: _: { })) [
|
overrides = final.lib.fold final.lib.composeExtensions (old.overrides or (_: _: { })) [
|
||||||
(final.haskell.lib.packageSourceOverrides {
|
(final.haskell.lib.packageSourceOverrides {
|
||||||
nix-serve-ng = ./.;
|
nix-serve-ng = ./.;
|
||||||
|
lix-serve-ng = ./.;
|
||||||
|
|
||||||
base16 = "1.0";
|
base16 = "1.0";
|
||||||
})
|
})
|
||||||
@ -37,6 +42,14 @@
|
|||||||
final.nixVersions.nix_2_28
|
final.nixVersions.nix_2_28
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
lix-serve-ng = final.haskell.lib.overrideCabal haskellPackagesOld.lix-serve-ng (old: {
|
||||||
|
pname = "lix-serve-ng";
|
||||||
|
configureFlags = (old.configureFlags or [ ]) ++ [ "-flix" ];
|
||||||
|
executableSystemDepends = (old.executableSystemDepends or [ ]) ++ [
|
||||||
|
final.boost.dev
|
||||||
|
final.lix
|
||||||
|
];
|
||||||
|
});
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
@ -46,6 +59,10 @@
|
|||||||
nix-serve-ng =
|
nix-serve-ng =
|
||||||
final.haskell.lib.justStaticExecutables
|
final.haskell.lib.justStaticExecutables
|
||||||
final.haskell.packages."${compiler}".nix-serve-ng;
|
final.haskell.packages."${compiler}".nix-serve-ng;
|
||||||
|
|
||||||
|
lix-serve-ng =
|
||||||
|
final.haskell.lib.justStaticExecutables
|
||||||
|
final.haskell.packages."${compiler}".lix-serve-ng;
|
||||||
};
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
@ -60,24 +77,36 @@
|
|||||||
inherit system;
|
inherit system;
|
||||||
};
|
};
|
||||||
|
|
||||||
inherit (pkgs) nix-serve-ng;
|
inherit (pkgs) nix-serve-ng lix-serve-ng;
|
||||||
|
|
||||||
in
|
in
|
||||||
rec {
|
rec {
|
||||||
packages.default = nix-serve-ng;
|
packages = {
|
||||||
|
inherit nix-serve-ng lix-serve-ng;
|
||||||
|
default = nix-serve-ng;
|
||||||
|
};
|
||||||
|
|
||||||
defaultPackage = packages.default;
|
defaultPackage = packages.default;
|
||||||
|
|
||||||
apps.default = {
|
apps = rec {
|
||||||
type = "app";
|
default = nix-serve-ng;
|
||||||
|
nix-serve-ng = {
|
||||||
program = "${nix-serve-ng}/bin/nix-serve";
|
type = "app";
|
||||||
|
program = "${nix-serve-ng}/bin/nix-serve";
|
||||||
|
};
|
||||||
|
lix-serve-ng = {
|
||||||
|
type = "app";
|
||||||
|
program = "${lix-serve-ng}/bin/nix-serve";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultApp = apps.default;
|
defaultApp = apps.default;
|
||||||
|
|
||||||
devShells.default =
|
devShells = rec {
|
||||||
(pkgs.haskell.lib.doBenchmark pkgs.haskell.packages."${compiler}".nix-serve-ng).env;
|
default = nix-serve-ng;
|
||||||
|
nix-serve-ng = (pkgs.haskell.lib.doBenchmark pkgs.haskell.packages."${compiler}".nix-serve-ng).env;
|
||||||
|
lix-serve-ng = (pkgs.haskell.lib.doBenchmark pkgs.haskell.packages."${compiler}".lix-serve-ng).env;
|
||||||
|
};
|
||||||
|
|
||||||
devShell = devShells.default;
|
devShell = devShells.default;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,11 @@ maintainer: opensource@awakesecurity.com
|
|||||||
copyright: 2022 Arista Networks
|
copyright: 2022 Arista Networks
|
||||||
extra-source-files: CHANGELOG.md
|
extra-source-files: CHANGELOG.md
|
||||||
|
|
||||||
|
Flag Lix
|
||||||
|
Description: Build against Lix
|
||||||
|
Default: False
|
||||||
|
Manual: True
|
||||||
|
|
||||||
executable nix-serve
|
executable nix-serve
|
||||||
hs-source-dirs: src
|
hs-source-dirs: src
|
||||||
|
|
||||||
@ -55,8 +60,14 @@ executable nix-serve
|
|||||||
, warp
|
, warp
|
||||||
, warp-tls
|
, warp-tls
|
||||||
|
|
||||||
pkgconfig-depends:
|
if flag(lix)
|
||||||
nix-store
|
cxx-options: -DLIX
|
||||||
|
pkgconfig-depends:
|
||||||
|
, lix-main
|
||||||
|
, lix-store
|
||||||
|
else
|
||||||
|
pkgconfig-depends:
|
||||||
|
nix-store
|
||||||
|
|
||||||
if os(darwin)
|
if os(darwin)
|
||||||
extra-libraries: c++
|
extra-libraries: c++
|
||||||
|
Loading…
x
Reference in New Issue
Block a user