From 52a6173f0bfbda2daa5492d0a529b0155dee4ada Mon Sep 17 00:00:00 2001 From: Schrottkatze Date: Tue, 16 Apr 2024 21:37:01 +0200 Subject: [PATCH] add rust support to config --- .gitignore | 1 + common.nix | 4 ++ flake.lock | 103 +++++++++++++++++++++++++++++--------- flake.nix | 32 ++++++++++-- programs/jrnl/Cargo.lock | 7 +++ programs/jrnl/Cargo.toml | 6 +++ programs/jrnl/src/main.rs | 3 ++ 7 files changed, 126 insertions(+), 30 deletions(-) create mode 100644 programs/jrnl/Cargo.lock create mode 100644 programs/jrnl/Cargo.toml create mode 100644 programs/jrnl/src/main.rs diff --git a/.gitignore b/.gitignore index 4812d58..8905c28 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ result .direnv/ +programs/*/target diff --git a/common.nix b/common.nix index d554103..21aa36d 100644 --- a/common.nix +++ b/common.nix @@ -5,6 +5,7 @@ config, pkgs, lib, + rs-programs, ... }: with lib; @@ -25,6 +26,7 @@ with builtins; { "nodejs-16.20.0" ]; }; + overlays = [rs-programs]; }; environment = { @@ -73,6 +75,8 @@ with builtins; { devd libjxl + + s10e-jrnl ]; }; diff --git a/flake.lock b/flake.lock index 7ae1d7c..7663640 100644 --- a/flake.lock +++ b/flake.lock @@ -41,6 +41,25 @@ "url": "https://gitlab.com/obsidianical/easymacros.git" } }, + "fenix": { + "inputs": { + "nixpkgs": "nixpkgs_4", + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1713248681, + "narHash": "sha256-wB/Hz8tP8xzNnfJotyeAWhxxe6R2BOI0DWOtDBFgEgc=", + "owner": "nix-community", + "repo": "fenix", + "rev": "402051dcf16bcaa14dcbd96d2d5b4a97664eb35c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": [ @@ -129,7 +148,7 @@ "gumseite": { "inputs": { "flake-utils": "flake-utils_2", - "nixpkgs": "nixpkgs_4" + "nixpkgs": "nixpkgs_5" }, "locked": { "lastModified": 1680175611, @@ -206,7 +225,7 @@ "karton": { "inputs": { "naersk": "naersk_2", - "nixpkgs": "nixpkgs_6", + "nixpkgs": "nixpkgs_7", "utils": "utils" }, "locked": { @@ -239,7 +258,7 @@ "meowsite": { "inputs": { "flake-utils": "flake-utils_3", - "nixpkgs": "nixpkgs_7" + "nixpkgs": "nixpkgs_8" }, "locked": { "lastModified": 1678920998, @@ -275,7 +294,7 @@ }, "naersk_2": { "inputs": { - "nixpkgs": "nixpkgs_5" + "nixpkgs": "nixpkgs_6" }, "locked": { "lastModified": 1671096816, @@ -294,7 +313,7 @@ }, "naersk_3": { "inputs": { - "nixpkgs": "nixpkgs_9" + "nixpkgs": "nixpkgs_10" }, "locked": { "lastModified": 1671096816, @@ -374,6 +393,20 @@ } }, "nixpkgs_10": { + "locked": { + "lastModified": 1675614288, + "narHash": "sha256-i3Rc/ENnz62BcrSloeVmAyPicEh4WsrEEYR+INs9TYw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d25de6654a34d99dceb02e71e6db516b3b545be6", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_11": { "locked": { "lastModified": 1675614288, "narHash": "sha256-i3Rc/ENnz62BcrSloeVmAyPicEh4WsrEEYR+INs9TYw=", @@ -418,6 +451,22 @@ } }, "nixpkgs_4": { + "locked": { + "lastModified": 1712963716, + "narHash": "sha256-WKm9CvgCldeIVvRz87iOMi8CFVB1apJlkUT4GGvA0iM=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "cfd6b5fc90b15709b780a5a1619695a88505a176", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_5": { "locked": { "lastModified": 1679966490, "narHash": "sha256-k0jV+y1jawE6w4ZvKgXDNg4+O9NNtcaWwzw8gufv0b4=", @@ -433,7 +482,7 @@ "type": "github" } }, - "nixpkgs_5": { + "nixpkgs_6": { "locked": { "lastModified": 1677852945, "narHash": "sha256-liiVJjkBTuBTAkRW3hrI8MbPD2ImYzwUpa7kvteiKhM=", @@ -447,7 +496,7 @@ "type": "indirect" } }, - "nixpkgs_6": { + "nixpkgs_7": { "locked": { "lastModified": 1677852945, "narHash": "sha256-liiVJjkBTuBTAkRW3hrI8MbPD2ImYzwUpa7kvteiKhM=", @@ -463,7 +512,7 @@ "type": "github" } }, - "nixpkgs_7": { + "nixpkgs_8": { "locked": { "lastModified": 1674407282, "narHash": "sha256-2qwc8mrPINSFdWffPK+ji6nQ9aGnnZyHSItVcYDZDlk=", @@ -479,7 +528,7 @@ "type": "github" } }, - "nixpkgs_8": { + "nixpkgs_9": { "locked": { "lastModified": 1712608508, "narHash": "sha256-vMZ5603yU0wxgyQeHJryOI+O61yrX2AHwY6LOFyV1gM=", @@ -494,36 +543,40 @@ "type": "indirect" } }, - "nixpkgs_9": { - "locked": { - "lastModified": 1675614288, - "narHash": "sha256-i3Rc/ENnz62BcrSloeVmAyPicEh4WsrEEYR+INs9TYw=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "d25de6654a34d99dceb02e71e6db516b3b545be6", - "type": "github" - }, - "original": { - "id": "nixpkgs", - "type": "indirect" - } - }, "root": { "inputs": { "arion": "arion", "easymacros": "easymacros", + "fenix": "fenix", "gumseite": "gumseite", "home-manager": "home-manager", "karton": "karton", "mac-brcm-fw": "mac-brcm-fw", "meowsite": "meowsite", "nixos-hardware": "nixos-hardware", - "nixpkgs": "nixpkgs_8", + "nixpkgs": "nixpkgs_9", "nixpkgs-stable": "nixpkgs-stable", "nixpkgs-unstable-small": "nixpkgs-unstable-small", "wordsofgod": "wordsofgod" } }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1713212246, + "narHash": "sha256-lkNQ/oqb1vyvAVcZ6s8Bf6X00SqbEhdU+kPLX+C+PW8=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "90cfa8035f98d3ab0f7f4f1e77f4f5e3b0a7370b", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, "utils": { "locked": { "lastModified": 1676283394, @@ -557,7 +610,7 @@ "wordsofgod": { "inputs": { "naersk": "naersk_3", - "nixpkgs": "nixpkgs_10", + "nixpkgs": "nixpkgs_11", "utils": "utils_2" }, "locked": { diff --git a/flake.nix b/flake.nix index ef869a2..c24ac67 100644 --- a/flake.nix +++ b/flake.nix @@ -21,6 +21,7 @@ karton.url = "git+https://gitlab.com/obsidianical/microbin.git"; arion.url = "github:hercules-ci/arion"; gumseite.url = "git+https://gitlab.com/schrottkatze/gum-schulsachen.git"; + fenix.url = "github:nix-community/fenix"; }; outputs = { @@ -31,10 +32,30 @@ home-manager, nixos-hardware, mac-brcm-fw, + fenix, ... } @ inputs: let - pkgs = nixpkgs.legacyPackages."x86_64-linux"; - pkgs-unstable-small = nixpkgs-unstable-small.legacyPackages."x86_64-linux"; + system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages.${system}; + pkgs-stable = nixpkgs-stable.legacyPackages.${system}; + pkgs-unstable-small = nixpkgs-unstable-small.legacyPackages.${system}; + rs-toolchain = with fenix.packages.${system}; + combine [ + default.toolchain + rust-analyzer + ]; + rs-platform = pkgs.makeRustPlatform { + cargo = rs-toolchain; + rustc = rs-toolchain; + }; + rs-programs = final: prev: { + s10e-jrnl = rs-platform.buildRustPackage { + pname = "jrnl"; + version = "0.0.1"; + src = ./programs/jrnl; + cargoLock.lockFile = ./programs/jrnl/Cargo.lock; + }; + }; in { devShells."x86_64-linux".default = pkgs.mkShell { buildInputs = [ @@ -46,13 +67,14 @@ xmobar statgrab ])) + rs-toolchain pkgs.haskell-language-server ]; }; nixosConfigurations = { monosodium-glutamate-g = nixpkgs.lib.nixosSystem { specialArgs = { - inherit inputs pkgs-unstable-small; + inherit inputs pkgs-unstable-small pkgs-stable rs-programs; }; system = "x86_64-linux"; modules = [ @@ -74,7 +96,7 @@ }; catbook-j = nixpkgs.lib.nixosSystem { specialArgs = { - inherit inputs pkgs-unstable-small; + inherit inputs pkgs-unstable-small pkgs-stable rs-programs; }; system = "x86_64-linux"; modules = [ @@ -96,7 +118,7 @@ }; potatobook-g = nixpkgs.lib.nixosSystem { specialArgs = { - inherit inputs pkgs-unstable-small; + inherit inputs pkgs-unstable-small rs-programs; }; system = "x86_64-linux"; modules = [ diff --git a/programs/jrnl/Cargo.lock b/programs/jrnl/Cargo.lock new file mode 100644 index 0000000..949dfbc --- /dev/null +++ b/programs/jrnl/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "jrnl" +version = "0.1.0" diff --git a/programs/jrnl/Cargo.toml b/programs/jrnl/Cargo.toml new file mode 100644 index 0000000..e8e395d --- /dev/null +++ b/programs/jrnl/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "jrnl" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/programs/jrnl/src/main.rs b/programs/jrnl/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/programs/jrnl/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +}