use flakes

Signed-off-by: Xe <me@christine.website>
This commit is contained in:
Cadey Ratio 2022-02-19 14:10:17 -05:00
parent 6898a868ee
commit 9b0a391482
8 changed files with 156 additions and 28 deletions

2
.envrc
View File

@ -1 +1 @@
eval "$(lorri direnv)"
use flake

13
.github/workflows/build_nix.yml vendored Normal file
View File

@ -0,0 +1,13 @@
name: "Build legacy Nix package on Ubuntu"
on:
push:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: cachix/install-nix-action@v12
- name: Building package
run: nix-build . -A defaultPackage.x86_64-linux

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
.#*
.direnv
/target
config.yaml
var/*

7
default.nix Normal file
View File

@ -0,0 +1,7 @@
(import (
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz";
sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2"; }
) {
src = ./.;
}).defaultNix

77
flake.lock Normal file
View File

@ -0,0 +1,77 @@
{
"nodes": {
"naersk": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1639947939,
"narHash": "sha256-pGsM8haJadVP80GFq4xhnSpNitYNQpaXk4cnA796Cso=",
"owner": "nmattia",
"repo": "naersk",
"rev": "2fc8ce9d3c025d59fee349c1f80be9785049d653",
"type": "github"
},
"original": {
"owner": "nmattia",
"ref": "master",
"repo": "naersk",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1645013224,
"narHash": "sha256-b7OEC8vwzJv3rsz9pwnTX2LQDkeOWz2DbKypkVvNHXc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b66b39216b1fef2d8c33cc7a5c72d8da80b79970",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1645013224,
"narHash": "sha256-b7OEC8vwzJv3rsz9pwnTX2LQDkeOWz2DbKypkVvNHXc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b66b39216b1fef2d8c33cc7a5c72d8da80b79970",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"naersk": "naersk",
"nixpkgs": "nixpkgs_2",
"utils": "utils"
}
},
"utils": {
"locked": {
"lastModified": 1644229661,
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

48
flake.nix Normal file
View File

@ -0,0 +1,48 @@
{
inputs = {
naersk.url = "github:nmattia/naersk/master";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, utils, naersk }:
utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
naersk-lib = pkgs.callPackage naersk { };
in {
defaultPackage = naersk-lib.buildPackage ./.;
defaultApp = utils.lib.mkApp { drv = self.defaultPackage."${system}"; };
devShell = with pkgs;
mkShell {
buildInputs = [
# rust
cargo
cargo-watch
rustc
rust-analyzer
rustfmt
rustPackages.clippy
# system
pkg-config
openssl
cmake
# dhall
dhall
dhall-json
jo
];
RUST_LOG = "info";
RUST_SRC_PATH = rustPlatform.rustLibSrc;
};
});
}

View File

@ -1,26 +1,7 @@
{ pkgs ? import <nixpkgs> { } }:
pkgs.mkShell {
buildInputs = with pkgs; [
# rust
cargo
cargo-watch
rustc
rust-analyzer
rustfmt
# system
pkg-config
openssl
cmake
# dhall
dhall
dhall-json
jo
];
RUST_LOG = "info";
RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}";
}
(import (
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz";
sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2"; }
) {
src = ./.;
}).shellNix

View File

@ -31,7 +31,8 @@ async fn main() -> Result<()> {
tracing_subscriber::fmt::init();
color_eyre::install()?;
let cfg: Config = serde_yaml::from_str(&std::fs::read_to_string("config.yaml")?)?;
let mut cfg: Config = serde_yaml::from_str(&std::fs::read_to_string("config.yaml")?)?;
cfg.irc.version = Some(APPLICATION_NAME.to_string());
let db = Arc::new(Mutex::new({
let db = Connection::open(cfg.database_path.clone())?;