/ flake.nix
flake.nix
1 { 2 description = "Simple shell in C for fun"; 3 4 inputs = { 5 nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; 6 }; 7 8 outputs = { self, nixpkgs }: 9 let 10 system = "x86_64-linux"; 11 pkgs = import nixpkgs { inherit system; }; 12 c-shell = pkgs.stdenv.mkDerivation { 13 name = "c-shell"; 14 version = "0.1"; 15 src = ./.; 16 17 buildPhase = '' 18 gcc -o c-shell shell.c 19 ''; 20 21 installPhase = '' 22 mkdir -p $out/bin 23 cp c-shell $out/bin/ 24 ''; 25 }; 26 in { 27 packages.${system} = { 28 c-shell = c-shell; 29 default = c-shell; 30 }; 31 32 devShells.${system} = { 33 default = pkgs.mkShell { 34 inputsFrom = [ c-shell ]; 35 buildInputs = with pkgs; [ 36 valgrind 37 ]; 38 shellHook = '' 39 user_shell=$(getent passwd $USER |awk -F: '{print $7}') 40 exec $user_shell 41 ''; 42 }; 43 }; 44 }; 45 }