diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..3ed609e --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1746663147, + "narHash": "sha256-Ua0drDHawlzNqJnclTJGf87dBmaO/tn7iZ+TCkTRpRc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "dda3dcd3fe03e991015e9a74b22d35950f264a54", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..72c7c09 --- /dev/null +++ b/flake.nix @@ -0,0 +1,64 @@ +{ + description = "R development shell"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + + outputs = + { self, nixpkgs, ... }: + let + system = "x86_64-linux"; + pkgs = import nixpkgs { + inherit system; + }; + quarto = pkgs.quarto.overrideAttrs (oldAttrs: rec { + installPhase = '' + runHook preInstall + + mkdir -p $out/bin $out/share + + mv bin/* $out/bin + mv share/* $out/share + + runHook postInstall + ''; + }); + in + { + devShells.x86_64-linux.default = pkgs.mkShell rec { + name = "R_environment"; + buildInputs = with pkgs; [ + # Technical dependencies: + R + python312Packages.radian + quarto + rPackages.languageserver + rPackages.lintr + rPackages.styler + rPackages.httpgd + rPackages.crayon + rPackages.cli + + # Actual R packages needed for the project: + rPackages.quarto + rPackages.tidyverse + rPackages.data_table + rPackages.anytime + rPackages.dbx + rPackages.RMySQL + rPackages.gamlss + rPackages.forecast + rPackages.tictoc + + ]; + + # Creating a symlink to the radian binary in the .bin directory is certainly not ideal. There is an isue on that: "https://github.com/REditorSupport/vscode-R/issues/1347" + # But it is the best way to make it work for now I guess. + shellHook = '' + mkdir -p .bin + ln -sf ${pkgs.python312Packages.radian}/bin/radian .bin/ + ''; + }; + }; +}