Port to dream2nix

This commit is contained in:
Sridhar Ratnakumar 2023-06-26 12:32:36 -04:00
parent d2996b6fd1
commit f3b4c3fd4f
4 changed files with 450 additions and 135 deletions

View file

@ -1,3 +0,0 @@
#!/usr/bin/env bash
set -xe
exec nix-shell --run 'cargo watch -x run'

View file

@ -1,13 +0,0 @@
(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

473
flake.lock generated
View file

@ -1,35 +1,47 @@
{ {
"nodes": { "nodes": {
"all-cabal-json": {
"flake": false,
"locked": {
"lastModified": 1665552503,
"narHash": "sha256-r14RmRSwzv5c+bWKUDaze6pXM7nOsiz1H8nvFHJvufc=",
"owner": "nix-community",
"repo": "all-cabal-json",
"rev": "d7c0434eebffb305071404edcf9d5cd99703878e",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "hackage",
"repo": "all-cabal-json",
"type": "github"
}
},
"crane": { "crane": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1644785799, "lastModified": 1681175776,
"narHash": "sha256-VpAJO1L0XeBvtCuNGK4IDKp6ENHIpTrlaZT7yfBCvwo=", "narHash": "sha256-7SsUy9114fryHAZ8p1L6G6YSu7jjz55FddEwa2U8XZc=",
"owner": "ipetkov", "owner": "ipetkov",
"repo": "crane", "repo": "crane",
"rev": "fc7a94f841347c88f2cb44217b2a3faa93e2a0b2", "rev": "445a3d222947632b5593112bb817850e8a9cf737",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "ipetkov", "owner": "ipetkov",
"ref": "v0.12.1",
"repo": "crane", "repo": "crane",
"type": "github" "type": "github"
} }
}, },
"devshell": { "devshell": {
"inputs": { "flake": false,
"flake-utils": "flake-utils",
"nixpkgs": [
"nci",
"nixpkgs"
]
},
"locked": { "locked": {
"lastModified": 1650900878, "lastModified": 1663445644,
"narHash": "sha256-qhNncMBSa9STnhiLfELEQpYC1L4GrYHNIzyCZ/pilsI=", "narHash": "sha256-+xVlcK60x7VY1vRJbNUEAHi17ZuoQxAIH4S4iUFUGBA=",
"owner": "numtide", "owner": "numtide",
"repo": "devshell", "repo": "devshell",
"rev": "d97df53b5ddaa1cfbea7cddbd207eb2634304733", "rev": "e3dc3e21594fe07bdb24bdf1c8657acaa4cb8f66",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -40,46 +52,29 @@
}, },
"dream2nix": { "dream2nix": {
"inputs": { "inputs": {
"alejandra": [ "all-cabal-json": "all-cabal-json",
"nci",
"nixpkgs"
],
"crane": "crane", "crane": "crane",
"flake-utils-pre-commit": [ "devshell": "devshell",
"nci", "drv-parts": "drv-parts",
"nixpkgs" "flake-compat": "flake-compat",
], "flake-parts": "flake-parts",
"gomod2nix": [ "flake-utils-pre-commit": "flake-utils-pre-commit",
"nci", "ghc-utils": "ghc-utils",
"nixpkgs" "gomod2nix": "gomod2nix",
], "mach-nix": "mach-nix",
"mach-nix": [ "nix-pypi-fetcher": "nix-pypi-fetcher",
"nci", "nixpkgs": "nixpkgs",
"nixpkgs" "nixpkgsV1": "nixpkgsV1",
], "poetry2nix": "poetry2nix",
"nixpkgs": [ "pre-commit-hooks": "pre-commit-hooks",
"nci", "pruned-racket-catalog": "pruned-racket-catalog"
"nixpkgs"
],
"node2nix": [
"nci",
"nixpkgs"
],
"poetry2nix": [
"nci",
"nixpkgs"
],
"pre-commit-hooks": [
"nci",
"nixpkgs"
]
}, },
"locked": { "locked": {
"lastModified": 1651844867, "lastModified": 1687429612,
"narHash": "sha256-a+bAmmeIudRVY23ZkEB5W5xJumBY3ydsiDIGN/56NmQ=", "narHash": "sha256-lVQlsVmWLQt+bgckBjiKxcqq2Jx1RYxyI3zmtdQ5Acs=",
"owner": "nix-community", "owner": "nix-community",
"repo": "dream2nix", "repo": "dream2nix",
"rev": "e5d0e9cdb00695b0b63d1f52ff3b39c0e3035fe3", "rev": "6b750b01385718a6a84231d3c5451308978fa7de",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -88,14 +83,43 @@
"type": "github" "type": "github"
} }
}, },
"drv-parts": {
"inputs": {
"flake-compat": [
"dream2nix",
"flake-compat"
],
"flake-parts": [
"dream2nix",
"flake-parts"
],
"nixpkgs": [
"dream2nix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1680698112,
"narHash": "sha256-FgnobN/DvCjEsc0UAZEAdPLkL4IZi2ZMnu2K2bUaElc=",
"owner": "davhau",
"repo": "drv-parts",
"rev": "e8c2ec1157dc1edb002989669a0dbd935f430201",
"type": "github"
},
"original": {
"owner": "davhau",
"repo": "drv-parts",
"type": "github"
}
},
"flake-compat": { "flake-compat": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1650374568, "lastModified": 1673956053,
"narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra", "owner": "edolstra",
"repo": "flake-compat", "repo": "flake-compat",
"rev": "b4a34015c698c7793d592d66adbab377907a2be8", "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -104,51 +128,208 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils": { "flake-parts": {
"locked": {
"lastModified": 1642700792,
"narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "846b2ae0fc4cc943637d3d1def4454213e203cba",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nci": {
"inputs": { "inputs": {
"devshell": "devshell", "nixpkgs-lib": [
"dream2nix": "dream2nix", "dream2nix",
"nixpkgs": [
"nixpkgs" "nixpkgs"
], ]
"rustOverlay": "rustOverlay"
}, },
"locked": { "locked": {
"lastModified": 1651990362, "lastModified": 1675933616,
"narHash": "sha256-Yw32A18l9hx/+19PcUhuoOLuBXtlrFoea7OAM3R4pzs=", "narHash": "sha256-/rczJkJHtx16IFxMmAWu5nNYcSXNg1YYXTHoGjLrLUA=",
"owner": "yusdacra", "owner": "hercules-ci",
"repo": "nix-cargo-integration", "repo": "flake-parts",
"rev": "d187cd7b1e8c85521c3bad633a79fd25f584f42e", "rev": "47478a4a003e745402acf63be7f9a092d51b83d7",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "yusdacra", "owner": "hercules-ci",
"repo": "nix-cargo-integration", "repo": "flake-parts",
"type": "github"
}
},
"flake-parts_2": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1687762428,
"narHash": "sha256-DIf7mi45PKo+s8dOYF+UlXHzE0Wl/+k3tXUyAoAnoGE=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "37dd7bb15791c86d55c5121740a1887ab55ee836",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-root": {
"locked": {
"lastModified": 1680964220,
"narHash": "sha256-dIdTYcf+KW9a4pKHsEbddvLVSfR1yiAJynzg2x0nfWg=",
"owner": "srid",
"repo": "flake-root",
"rev": "f1c0b93d05bdbea6c011136ba1a135c80c5b326c",
"type": "github"
},
"original": {
"owner": "srid",
"repo": "flake-root",
"type": "github"
}
},
"flake-utils-pre-commit": {
"locked": {
"lastModified": 1644229661,
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"ghc-utils": {
"flake": false,
"locked": {
"lastModified": 1662774800,
"narHash": "sha256-1Rd2eohGUw/s1tfvkepeYpg8kCEXiIot0RijapUjAkE=",
"ref": "refs/heads/master",
"rev": "bb3a2d3dc52ff0253fb9c2812bd7aa2da03e0fea",
"revCount": 1072,
"type": "git",
"url": "https://gitlab.haskell.org/bgamari/ghc-utils"
},
"original": {
"type": "git",
"url": "https://gitlab.haskell.org/bgamari/ghc-utils"
}
},
"gomod2nix": {
"flake": false,
"locked": {
"lastModified": 1627572165,
"narHash": "sha256-MFpwnkvQpauj799b4QTBJQFEddbD02+Ln5k92QyHOSk=",
"owner": "tweag",
"repo": "gomod2nix",
"rev": "67f22dd738d092c6ba88e420350ada0ed4992ae8",
"type": "github"
},
"original": {
"owner": "tweag",
"repo": "gomod2nix",
"type": "github"
}
},
"mach-nix": {
"flake": false,
"locked": {
"lastModified": 1634711045,
"narHash": "sha256-m5A2Ty88NChLyFhXucECj6+AuiMZPHXNbw+9Kcs7F6Y=",
"owner": "DavHau",
"repo": "mach-nix",
"rev": "4433f74a97b94b596fa6cd9b9c0402104aceef5d",
"type": "github"
},
"original": {
"id": "mach-nix",
"type": "indirect"
}
},
"mission-control": {
"locked": {
"lastModified": 1683658484,
"narHash": "sha256-JkGnWyYZxOnyOhztrxLSqaod6+O/3rRypq0dAqA/zn0=",
"owner": "Platonic-Systems",
"repo": "mission-control",
"rev": "a0c93bd764a3c25e6999397e9f5f119c1b124e38",
"type": "github"
},
"original": {
"owner": "Platonic-Systems",
"repo": "mission-control",
"type": "github"
}
},
"nix-pypi-fetcher": {
"flake": false,
"locked": {
"lastModified": 1669065297,
"narHash": "sha256-UStjXjNIuIm7SzMOWvuYWIHBkPUKQ8Id63BMJjnIDoA=",
"owner": "DavHau",
"repo": "nix-pypi-fetcher",
"rev": "a9885ac6a091576b5195d547ac743d45a2a615ac",
"type": "github"
},
"original": {
"owner": "DavHau",
"repo": "nix-pypi-fetcher",
"type": "github" "type": "github"
} }
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1651558728, "lastModified": 1665580254,
"narHash": "sha256-8HzyRnWlgZluUrVFNOfZAOlA1fghpOSezXvxhalGMUo=", "narHash": "sha256-hO61XPkp1Hphl4HGNzj1VvDH5URt7LI6LaY/385Eul4=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "f634d427b0224a5f531ea5aa10c3960ba6ec5f0f",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-unstable",
"type": "indirect"
}
},
"nixpkgs-lib": {
"locked": {
"dir": "lib",
"lastModified": 1685564631,
"narHash": "sha256-8ywr3AkblY4++3lIVxmrWZFzac7+f32ZEhH/A8pNscI=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "4f53efe34b3a8877ac923b9350c874e3dcd5dc0a",
"type": "github"
},
"original": {
"dir": "lib",
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgsV1": {
"locked": {
"lastModified": 1686501370,
"narHash": "sha256-G0WuM9fqTPRc2URKP9Lgi5nhZMqsfHGrdEbrLvAPJcg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "75a5ebf473cd60148ba9aec0d219f72e5cf52519",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-unstable",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1687681650,
"narHash": "sha256-M2If+gRcfpmaJy/XbfSsRzLlPpoU4nr0NHnKKl50fd8=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "cbe587c735b734405f56803e267820ee1559e6c1", "rev": "1c9db9710cb23d60570ad4d7ab829c2d34403de3",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -158,26 +339,122 @@
"type": "github" "type": "github"
} }
}, },
"root": { "nixpkgs_3": {
"inputs": {
"flake-compat": "flake-compat",
"nci": "nci",
"nixpkgs": "nixpkgs"
}
},
"rustOverlay": {
"flake": false,
"locked": { "locked": {
"lastModified": 1651977622, "lastModified": 1680945546,
"narHash": "sha256-M3vm6mz+ypilmw3hkA6/GyDHH7ID85jWqeE9rtPWe8k=", "narHash": "sha256-8FuaH5t/aVi/pR1XxnF0qi4WwMYC+YxlfdsA0V+TEuQ=",
"owner": "oxalica", "owner": "nixos",
"repo": "rust-overlay", "repo": "nixpkgs",
"rev": "c66fab76467a5df683ef50724a7bde54c315f967", "rev": "d9f759f2ea8d265d974a6e1259bd510ac5844c5d",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "oxalica", "owner": "nixos",
"repo": "rust-overlay", "ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"poetry2nix": {
"flake": false,
"locked": {
"lastModified": 1666918719,
"narHash": "sha256-BkK42fjAku+2WgCOv2/1NrPa754eQPV7gPBmoKQBWlc=",
"owner": "nix-community",
"repo": "poetry2nix",
"rev": "289efb187123656a116b915206e66852f038720e",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "1.36.0",
"repo": "poetry2nix",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-utils": [
"dream2nix",
"flake-utils-pre-commit"
],
"nixpkgs": [
"dream2nix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1646153636,
"narHash": "sha256-AlWHMzK+xJ1mG267FdT8dCq/HvLCA6jwmx2ZUy5O8tY=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "b6bc0b21e1617e2b07d8205e7fae7224036dfa4b",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"pruned-racket-catalog": {
"flake": false,
"locked": {
"lastModified": 1672537287,
"narHash": "sha256-SuOvXVcLfakw18oJB/PuRMyvGyGG1+CQD3R+TGHIv44=",
"owner": "nix-community",
"repo": "pruned-racket-catalog",
"rev": "c8b89557fb53b36efa2ee48a769c7364df0f6262",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "catalog",
"repo": "pruned-racket-catalog",
"type": "github"
}
},
"root": {
"inputs": {
"dream2nix": "dream2nix",
"flake-parts": "flake-parts_2",
"flake-root": "flake-root",
"mission-control": "mission-control",
"nixpkgs": "nixpkgs_2",
"systems": "systems",
"treefmt-nix": "treefmt-nix"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1687600980,
"narHash": "sha256-Tbu9Hj7JVX+rCYyUPJNQTPQqw382ahAFNoDVTrXnjFk=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "b100498935f04a70605dfde0edc6e311d865b869",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github" "type": "github"
} }
} }

View file

@ -1,30 +1,84 @@
# This file is pretty general, and you can adapt it in your project replacing
# only `name` and `description` below.
{ {
description = "My awesome Rust project";
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-compat = { flake-parts.url = "github:hercules-ci/flake-parts";
url = "github:edolstra/flake-compat"; systems.url = "github:nix-systems/default";
flake = false;
}; # Rust
nci.url = "github:yusdacra/nix-cargo-integration"; dream2nix.url = "github:nix-community/dream2nix";
nci.inputs.nixpkgs.follows = "nixpkgs";
# Dev tools
treefmt-nix.url = "github:numtide/treefmt-nix";
mission-control.url = "github:Platonic-Systems/mission-control";
flake-root.url = "github:srid/flake-root";
}; };
outputs = { self, nixpkgs, nci, ... }: outputs = inputs:
nci.lib.makeOutputs { inputs.flake-parts.lib.mkFlake { inherit inputs; } {
# Documentation and examples: systems = import inputs.systems;
# https://github.com/yusdacra/rust-nix-templater/blob/master/template/flake.nix imports = [
root = ./.; inputs.dream2nix.flakeModuleBeta
overrides = { inputs.treefmt-nix.flakeModule
shell = common: prev: { inputs.mission-control.flakeModule
packages = prev.packages ++ [ inputs.flake-root.flakeModule
common.pkgs.rust-analyzer ];
common.pkgs.cargo-watch perSystem = { config, self', pkgs, lib, system, ... }: {
# Rust project definition
# cf. https://github.com/nix-community/dream2nix
dream2nix.inputs."rust-nix-template" = {
source = lib.sourceFilesBySuffices ./. [
".rs"
"Cargo.toml"
"Cargo.lock"
]; ];
projects."rust-nix-template" = { name, ... }: {
inherit name;
subsystem = "rust";
translator = "cargo-lock";
};
};
# Flake outputs
packages = config.dream2nix.outputs.rust-nix-template.packages;
devShells.default = pkgs.mkShell {
inputsFrom = [
config.dream2nix.outputs.rust-nix-template.devShells.default
config.treefmt.build.devShell
config.mission-control.devShell
config.flake-root.devShell
];
nativeBuildInputs = [
pkgs.cargo-watch
];
};
# Add your auto-formatters here.
# cf. https://numtide.github.io/treefmt/
treefmt.config = {
projectRootFile = "flake.nix";
programs = {
nixpkgs-fmt.enable = true;
rustfmt.enable = true;
};
};
# Makefile'esque but in Nix. Add your dev scripts here.
# cf. https://github.com/Platonic-Systems/mission-control
mission-control.scripts = {
fmt = {
exec = config.treefmt.build.wrapper;
description = "Auto-format project tree";
};
run = {
exec = ''cargo run'';
description = "Run the project executable";
};
watch = {
exec = ''cargo watch -x run'';
description = "Watch for changes and run the project executable";
};
}; };
}; };
}; };