add flake.nix

This commit is contained in:
lia
2025-09-14 12:16:34 +02:00
parent 48f1b29083
commit 6ee8b07d06
5 changed files with 315 additions and 164 deletions

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
target/ target/
.idea/ .idea/
Cargo.lock Cargo.lock
flake.lock

113
flake.lock generated Normal file
View File

@@ -0,0 +1,113 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gitignore": {
"flake": false,
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1757487488,
"narHash": "sha256-zwE/e7CuPJUWKdvvTCB7iunV4E/+G0lKfv4kk/5Izdg=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "ab0f3607a6c7486ea22229b92ed2d355f1482ee0",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1744536153,
"narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"gitignore": "gitignore",
"nixpkgs": "nixpkgs",
"rustup": "rustup"
}
},
"rustup": {
"inputs": {
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1757730403,
"narHash": "sha256-Jxl4OZRVsXs8JxEHUVQn3oPu6zcqFyGGKaFrlNgbzp0=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "3232f7f8bd07849fc6f4ae77fe695e0abb2eba2c",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

38
flake.nix Normal file
View File

@@ -0,0 +1,38 @@
{
description = "cutie flake ~";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
gitignore = { url = "github:hercules-ci/gitignore.nix"; flake = false; };
flake-utils.url = "github:numtide/flake-utils";
rustup.url = "github:oxalica/rust-overlay";
};
outputs = inputs@{ self, nixpkgs, flake-utils, rustup, ... }:
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system: let
overlays = [ (import rustup) ];
pkgs = import nixpkgs { inherit system overlays; };
libPath = with pkgs; lib.makeLibraryPath [
libGL libxkbcommon
wayland wayland-utils
musl musl-fts musl-obstack
makeWrapper pkg-config gcc
libiconv libtool autoconf automake
];
gitignoreSrc = pkgs.callPackage inputs.gitignore { };
in rec {
packages.hello = pkgs.callPackage ./default.nix { inherit gitignoreSrc; };
legacyPackages = packages;
defaultPackage = packages.hello;
devShell = pkgs.mkShell {
CARGO_INSTALL_ROOT = "${toString ./.}/.cargo";
RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}";
LD_LIBRARY_PATH = libPath;
buildInputs = with pkgs; [ (rust-bin.selectLatestNightlyWith (toolchain: toolchain.complete.override {
targets = [ "x86_64-unknown-linux-musl" "wasm32-unknown-unknown" ];
})) ];
};
});
}

View File

@@ -145,7 +145,7 @@ impl eframe::App for CatnipApp {
.wrap_mode(TextWrapMode::Wrap) .wrap_mode(TextWrapMode::Wrap)
.selected_text(format!("{:?}", theme)) .selected_text(format!("{:?}", theme))
.show_ui(ui, |ui| { .show_ui(ui, |ui| {
ui.selectable_value(&mut theme, ThemePreference::System, "💻 System", ); ui.selectable_value(&mut theme, ThemePreference::System, "💻 System");
ui.selectable_value(&mut theme, ThemePreference::Light, "☀ Light"); ui.selectable_value(&mut theme, ThemePreference::Light, "☀ Light");
ui.selectable_value(&mut theme, ThemePreference::Dark, "🌙 Dark"); ui.selectable_value(&mut theme, ThemePreference::Dark, "🌙 Dark");
}); });

View File

@@ -1,5 +1,5 @@
use application_catnip::CatnipApp; use application_catnip::CatnipApp;
use eframe::Renderer; use eframe::{wgpu, Renderer};
fn main() { fn main() {
env_logger::init(); env_logger::init();
@@ -7,7 +7,7 @@ fn main() {
"Catnip Editor", "Catnip Editor",
eframe::NativeOptions { eframe::NativeOptions {
centered: true, centered: true,
renderer: Renderer::Wgpu, renderer: Renderer::Glow,
viewport: egui::ViewportBuilder::default() viewport: egui::ViewportBuilder::default()
.with_inner_size([400.0, 300.0]) .with_inner_size([400.0, 300.0])
.with_min_inner_size([300.0, 220.0]), .with_min_inner_size([300.0, 220.0]),
@@ -17,6 +17,5 @@ fn main() {
egui_extras::install_image_loaders(&context.egui_ctx); egui_extras::install_image_loaders(&context.egui_ctx);
Ok(Box::<CatnipApp>::default()) Ok(Box::<CatnipApp>::default())
}), }),
) ).expect("TODO: panic message");
.expect("TODO: panic message");
} }