Skip to content
Snippets Groups Projects
Commit 8a10ae84 authored by Akshay Mankar's avatar Akshay Mankar
Browse files

Use nix-flakes

parent 91d1ea5b
No related branches found
No related tags found
No related merge requests found
env="$(nix-build $PWD/direnv.nix -A env)" use flake;
load_prefix "${env}"
result result
dist-newstyle dist-newstyle
.dir-locals.el .dir-locals.el
\ No newline at end of file .direnv
\ No newline at end of file
...@@ -33,7 +33,8 @@ used. ...@@ -33,7 +33,8 @@ used.
``` ```
- Using [nix](https://nixos.org/): - Using [nix](https://nixos.org/):
```bash ```bash
nix-env -f https://git.coop/akshay/terraform-http-backend-pass/-/archive/main/terraform-http-backend-pass-main.tar.gz -i nix registry add terraform-http-backend-pass git+https://git.coop/akshay/terraform-http-backend-pass
nix build 'terraform-http-backend-pass#' --profile $HOME/.nix-profile
``` ```
2. Create a pass repository: 2. Create a pass repository:
```bash ```bash
......
packages: . packages: .
\ No newline at end of file
source-repository-package
type: git
location: https://github.com/haskell-servant/servant.git
tag: 27173c922311112dd153346cf3cd72b9fb0f3551
subdir: servant servant-server
\ No newline at end of file
let sources = import ./nix/sources.nix; { mkDerivation, aeson, base, bytestring, directory, lib, mtl
in { pkgs ? import sources.nixpkgs {}, , optparse-applicative, optparse-generic, servant, servant-server
compiler ? "ghc8103" , shelly, text, warp
}: }:
let mkDerivation {
servantPkgs = import sources.servant {inherit pkgs compiler; }; pname = "terraform-http-backend-pass";
overrides = self: super: { version = "0.1.0.0";
terraform-http-backend-pass = self.callCabal2nix "terraform-http-backend-pass" ./. {}; src = ./.;
servant = servantPkgs.servant; isLibrary = true;
servant-server = servantPkgs.servant-server; isExecutable = true;
}; libraryHaskellDepends = [
hPkgs = pkgs.haskell.packages.${compiler}.override { inherit overrides; }; aeson base bytestring directory mtl optparse-applicative
in hPkgs.terraform-http-backend-pass optparse-generic servant servant-server shelly text warp
];
executableHaskellDepends = [ base ];
homepage = "https://github.com/akshaymankar/terraform-http-backend-pass#readme";
description = "HTTP backend to store terraform state using pass and git";
license = "AGPL";
}
let
sources = import ./nix/sources.nix;
pkgs = import sources.nixpkgs {};
in {
env = pkgs.buildEnv {
name = "terraform-http-backend-pass";
paths = with pkgs; [
pass
niv
gnumake
haskell-language-server
cabal-install
haskell.compiler.ghc8103 # HLS doesn't support GHC 9 yet.
zlib.dev
zlib
];
};
}
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1649676176,
"narHash": "sha256-OWKJratjt2RW151VUlJPRALb7OU2S5s+f0vLj4o1bHM=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "a4b154ebbdc88c8498a5c7b01589addc9e9cb678",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1651114127,
"narHash": "sha256-/lLC0wkMZkAdA5e1W76SnJzbhfOGDvync3VRHJMtAKk=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "6766fb6503ae1ebebc2a9704c162b2aef351f921",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}
{
description = "A very basic flake";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = {nixpkgs, flake-utils, ...}:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {inherit system;};
hlib = pkgs.haskell.lib;
# Avoids unnecessary recompiles
filteredSource = pkgs.lib.cleanSourceWith {
src = ./.;
filter = path: type:
let baseName = baseNameOf (toString path);
in pkgs.lib.cleanSourceFilter path type && !(
baseName == "flake.nix" ||
baseName == "flake.lock" ||
baseName == "dist-newstyle" ||
baseName == "nix" ||
builtins.match "^cabal\.project\..*$" baseName != null ||
baseName == ".envrc" ||
baseName == "hie.yaml" ||
baseName == ".hlint.yaml" ||
baseName == ".hspec"
);
};
haskellPackages = pkgs.haskell.packages.ghc8107.override {
overrides = hself: hsuper:
{
terraform-http-backend-pass = hlib.overrideSrc (hself.callPackage ./default.nix {}) {src = filteredSource;};
};
};
in rec {
packages = {
terraform-http-backend-pass = haskellPackages.terraform-http-backend-pass;
dev-shell = haskellPackages.shellFor {
packages = p: [p.terraform-http-backend-pass];
buildInputs = [
pkgs.cabal-install
pkgs.haskell.packages.ghc8107.haskell-language-server
pkgs.cabal2nix
pkgs.pass
];
};
};
defaultPackage = packages.terraform-http-backend-pass;
devShell = packages.dev-shell;
});
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment