Giter Site home page Giter Site logo

buck2-nix's Introduction

buck2-nix

NOTE: This repository is extremely experimental and may change radically. You probably don't want to be here unless you talk to me. Please see issue #1 for some design notes and feel free to provide input.

An experiment to integrate Buck2, Sapling, and Nix together in a harmonious way. Because this uses a pre-release Buck as well as our own Buck prelude to integrate with Nix, we're on our own.

You MUST have direnv installed. Everything else — including the correct tool versions — will be populated in your shell by direnv automatically when you move here.

There are some design notes in the buck/ directory. This is an experiment. Nothing is stable and everything is permitted. Do not taunt happy fun ball.

requirements

  1. direnv installed into your shell
  2. nix 2.14.0 or newer
  3. trusted-users includes your $USER

direnv will warn you if either 2 or 3 are not satisfied when you move into this directory. See .envrc for details. The automated setup tool also warns you about these facts.

fully automated setup

Experiment: what if we used nix run as an "setup tool" to setup direnv and nix's configuration? In other words, use it to bootstrap the development environment? And what if I wrote it in Rust to learn more of it?

Run this command from your $HOME (or any directory, but it won't touch the current working dir):

nix run \
    --tarball-ttl 0 \
    --accept-flake-config \
    'github:thoughtpolice/buck2-nix?dir=buck/nix#setup'

This tool will set up everything to build this repository correctly, and (by default) clone a copy of the source code for you, under $HOME. I hope. The goal is that Nix along with the above command should be able to completely bootstrap your working environment. If it doesn't work, please let me know. Check out the source code under ./buck/nix/setup/

treading water

Assuming the setup tool worked with the default configuration to clone under $HOME:

cd $HOME/buck2-nix.sl

This will activate direnv automatically — assuming nothing exploded — and buck --version should now work. This early "bootstrap phase" is intended to be as lightweight as possible, with the minimal tooling needed for everything else to work; so only buck and other critical tools are installed into your shell environment at this point.

Now, build whole repo. The build is automatically configured (via flake configuration) to use my upstream binary cache — this is why you being a trusted user is so strongly emphasized, so it's fully automatic — to download all tools needed on demand.

buck build ... # equivalent to root//...

Much like how Nix works, in this design, Buck only commands Nix to downloads things as they're needed; e.g. rust-stable will only be downloaded through nix build the moment it's needed for a Buck rule, and a target using that rule was demanded. So if you only build one component of the repository, only a small subset of Nix paths are downloaded. This "lazy" design is a distinct difference from a typical direnv setup with Nix Flakes, which are "eager" to put things in your shell environment immediately.

And so, the very first time you run this, you'll see many Nix paths downloading into your store from the binary cache.

Now, clean buck-out/, then kill the buck2d daemon

buck clean

You can finally move out of the directory, and buck will go away:

cd $HOME

buck2-nix's People

Contributors

actions-user avatar mayl avatar thoughtpolice avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

buck2-nix's Issues

What's the intended way to use this repo?

So, this repo sets up buck + watchman + makes the rules prelude available. But it also just clones the whole repo wholesale, including examples, setup/update scripts etc.

So far I've ran the setup script and then I've been adding my own project stuff on top to src, some tools in tools and so on. But I probably don't want/need this whole repo and its history so I've been thinking that I should start to selectively delete the stuff that doesn't seem necessary for me. At the same time, once I want to update the rules or buck exprs, I need to update the relevant contents...

What's the expected workflow? Should there be some separation between buck/prelude that users pull in and the rest of the repo? Should it be a submodule somehow maybe? I'm not sure.

setup: Choosing `n` when asked for confirmation makes it think it finished all the work

I hit n when asked for confirmation.

🎉  Setup complete!

✔ Which source code management tool do you want to use? · 3) 👴 Git     (Classic)
✔ What directory would you like to clone the repository into? · /home/shana/programming/buck2-nix-experiment/
✔ What name would you like to use for the cloned checkout? · buck2-nix.git
? I'm going to:

    Clone the repository https://github.com/thoughtpolice/buck2-nix
     into the directory  /home/shana/programming/buck2-nix-experiment//buck2-nix.git
        using 👴 Git
✔ Finished! 🎉 🎉 🎉

  You can now 'cd' into '/home/shana/programming/buck2-nix-experiment//buck2-nix.git' and begin developing!

  Upon doing so, direnv will activate, populating your shell with the needed environment.

nix.rules.build seems to struggle with multiple-output expressions

If I try to do the below

nix.rules.build(
    name = "jq",
    expr = "pkgs.jq",
    visibility = [ "root//..." ],
)

and use it somewhere, it will fail:

Required outputs are missing: Action failed to produce outputs: `buck-out/v2/gen/root/632fe5438d4aecc1/tools/__jq__/out.link`

because

[shana@aya:~/programming/tenchu-buck]$ ls -lha buck-out/v2/gen/root/632fe5438d4aecc1/tools/__jq__/
total 16K
drwxr-xr-x 2 shana users 4.0K May  1 22:46 .
drwxr-xr-x 7 shana users 4.0K May  1 22:39 ..
-rw-r--r-- 1 shana users  146 May  1 22:46 build.nix
-rwxr-xr-x 1 shana users  487 May  1 22:46 build.sh
lrwxrwxrwx 1 shana users   54 May  1 22:46 out.link-bin -> /nix/store/3x7qsswi5q7ibd5gifjnhggbry0y9920-jq-1.6-bin
lrwxrwxrwx 1 shana users   54 May  1 22:46 out.link-man -> /nix/store/j81k5f746lxlj8jp4gm19ni15qhy83wg-jq-1.6-man

A workaround is to use pkgs.jq.out as the expr. pkgs.jq.bin does not work.

Maybe at least add a field which allows to specify the link name so it's a middle-ground?

CI caching is kind of broken and needs to be fixed

Because I am insane, I have written yet another Nix binary caching server, which is supposed to exist on https://buck2-nix-cache.aseipp.dev/ and still does. But uploads don't work right now. Part of this is because I think my Cloudflare R2 access key expired? I can't remember all the details right now.

But anyway, the uploading phase is broken at the moment so you don't get cache hits for buck2 or setup, both of which take time to build, so that's pretty lame.

Leaving trailing slash when specifying directory results in double slash in the script.

✔ What directory would you like to clone the repository into? · /home/shana/programming/buck2-nix-experiment/
✔ What name would you like to use for the cloned checkout? · buck2-nix.git
? I'm going to:

    Clone the repository https://github.com/thoughtpolice/buck2-nix
     into the directory  /home/shana/programming/buck2-nix-experiment//buck2-nix.git

Fully automated setup command doesn't work.

[shana@aya:~/programming]$ cd buck2-nix-experiment/

[shana@aya:~/programming/buck2-nix-experiment]$ nix run \
    --tarball-ttl 0 \
    --accept-flake-config \
    'github:thoughtpolice/buck2-nix?dir=buck/nix#setup'
error:
       … while evaluating the attribute 'packages'

         at /nix/store/hafdh6gwaaw32zfgkckdny4rdkcicxvy-source/buck/nix/flake.nix:162:9:

          161|         inherit (jobs) devShells;
          162|         packages = rec {
             |         ^
          163|           # By default, build all the packages in the tree when just running

       … in the right operand of the update (//) operator

         at /nix/store/hafdh6gwaaw32zfgkckdny4rdkcicxvy-source/buck/nix/flake.nix:182:11:

          181|           # toolchains, et cetera.
          182|         } // flatJobs;
             |           ^
          183|

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: getting status of '/nix/store/hafdh6gwaaw32zfgkckdny4rdkcicxvy-source/buck/nix/toolchains': No such file or directory

[shana@aya:~/programming/buck2-nix-experiment]$ nix --version
nix (Nix) 2.14.1

[shana@aya:~/programming/buck2-nix-experiment]$ nix run     --tarball-ttl 0     --accept-flake-config     'github:thoughtpolice/buck2-nix?dir=buck/nix#setup' --show-trace
error:
       … while evaluating the attribute 'packages'

         at /nix/store/hafdh6gwaaw32zfgkckdny4rdkcicxvy-source/buck/nix/flake.nix:162:9:

          161|         inherit (jobs) devShells;
          162|         packages = rec {
             |         ^
          163|           # By default, build all the packages in the tree when just running

       … in the right operand of the update (//) operator

         at /nix/store/hafdh6gwaaw32zfgkckdny4rdkcicxvy-source/buck/nix/flake.nix:182:11:

          181|           # toolchains, et cetera.
          182|         } // flatJobs;
             |           ^
          183|

       … from call site

         at /nix/store/hafdh6gwaaw32zfgkckdny4rdkcicxvy-source/buck/nix/flake.nix:155:20:

          154|         # Flatten the hierarchy; mostly used to ensure we build everything...
          155|         flatJobs = flake-utils.lib.flattenTree rec {
             |                    ^
          156|           packages = jobs.packages // { recurseForDerivations = true; };

       … while calling 'flattenTree'

         at /nix/store/fy3x5qk811q1kjilcv1416p311pfh1a5-source/default.nix:171:17:

          170|   #   }
          171|   flattenTree = tree: import ./flattenTree.nix tree;
             |                 ^
          172|

       … from call site

         at /nix/store/fy3x5qk811q1kjilcv1416p311pfh1a5-source/default.nix:171:23:

          170|   #   }
          171|   flattenTree = tree: import ./flattenTree.nix tree;
             |                       ^
          172|

       … while calling anonymous lambda

         at /nix/store/fy3x5qk811q1kjilcv1416p311pfh1a5-source/flattenTree.nix:1:1:

            1| tree:
             | ^
            2| let

       … from call site

         at /nix/store/fy3x5qk811q1kjilcv1416p311pfh1a5-source/flattenTree.nix:35:1:

           34| in
           35| recurse { } [ ] tree
             | ^
           36|

       … while calling 'recurse'

         at /nix/store/fy3x5qk811q1kjilcv1416p311pfh1a5-source/flattenTree.nix:28:24:

           27|
           28|   recurse = sum: path: val:
             |                        ^
           29|     builtins.foldl'

       … while calling anonymous lambda

         at /nix/store/fy3x5qk811q1kjilcv1416p311pfh1a5-source/flattenTree.nix:30:13:

           29|     builtins.foldl'
           30|       (sum: key: op sum (path ++ [ key ]) val.${key})
             |             ^
           31|       sum

       … from call site

         at /nix/store/fy3x5qk811q1kjilcv1416p311pfh1a5-source/flattenTree.nix:30:18:

           29|     builtins.foldl'
           30|       (sum: key: op sum (path ++ [ key ]) val.${key})
             |                  ^
           31|       sum

       … while calling 'op'

         at /nix/store/fy3x5qk811q1kjilcv1416p311pfh1a5-source/flattenTree.nix:3:19:

            2| let
            3|   op = sum: path: val:
             |                   ^
            4|     let

       error: getting status of '/nix/store/hafdh6gwaaw32zfgkckdny4rdkcicxvy-source/buck/nix/toolchains': No such file or directory

Alternative sysroots

Not quite sure how to ask this so well asking

How could this be used to create and use an alternate (not nixos) sysroot.

My usecase is drag the toolchain from the void ^H^H^H^H nixos but provide a sysroot from something old, gross and crufty.

My needs are:

  • Cross compilation linux -> OSX M1 (for example)
  • Linux binaries for RHEL7

Remote Execution should be supported (work in progress)

As of sometime late last night, there is experimental support for running a local instance of buildbarn, with the goal of being able to use buck2's remote execution facilities to provide hermetic builds. You can go into the shell environment (i.e. cd into this directory) and type this:

start-buildbarn-vm

This will start a QEMU virtual machine, running NixOS. You can SSH into it:

$ ssh-keygen -f "$HOME/.ssh/known_hosts" -R "[localhost]:2222" && ssh -p 2222 -o "StrictHostKeyChecking no" root@localhost

# Host [localhost]:2222 found: line 6
/home/austin/.ssh/known_hosts updated.
Original contents retained as /home/austin/.ssh/known_hosts.old
Warning: Permanently added '[localhost]:2222' (ED25519) to the list of known hosts.
(root@localhost) Password: 
Last login: Fri Apr 14 05:42:17 2023 from 10.0.2.2

[root@nixos:~]# 

Then, once you're inside, start running buildbarn. This uses docker-compose (which is officially supported by them):

[root@nixos:~]# run-buildbarn

Wait a while. Now, you can visit either http://localhost:7982/ or http://localhost:7984/ to view the scheduler and blob storage web UI for buildbarn, respectively. The local GRPC API for Remote Execution is available at http://127.0.0.1:8980; you can use grpcurl -plaintext to get at it, and this is where we point buck.

Now, set the following to true in .buckconfig, and restart buck. You can leave the API addresses as usual; they aren't used unless re_enabled is set to true:

[buck2_re_client]
re_enabled = true
buck clean; rm -rf buck-out

This will use the GRPC API and BuildBarn containers! You can see the action logs if you look at the output of the run-buildbarn command (which will tail the output of every docker container.) But it fails, currently:

austin@GANON:~/src/buck2-nix.sl$ buck build ...
watchman fresh instance event, clearing cache
Action failed: root//src/renode:hifive-unleashed-vmlinux.bin (download_file https://dl.antmicro.com/projects/renode/hifive-unleashed--vmlinux.elf-s_80421976-46788813c50dc7eb1a1a33c1730ca633616f75f5)
Remote command returned non-zero exit code 127
stdout:
env dump
PWD=/worker/build/3d5ea13ec9268cfc/root
SHLVL=1
_=/usr/bin/env
ok
stderr:
buck-out/v2/gen/root/632fe5438d4aecc1/src/renode/__hifive-unleashed-vmlinux.bin__/download_hifive-unleashed-vmlinux.bin.sh: line 6: curl: command not found
Action failed: prelude//toolchains:nixpkgs-overlay-rust (download_tarball https://github.com/oxalica/rust-overlay/archive/1373567ffd13719f6b7522737b010bfc514d49b4.tar.gz)
Remote command returned non-zero exit code 127
stdout:
stderr:
buck-out/v2/gen/prelude/632fe5438d4aecc1/toolchains/__nixpkgs-overlay-rust__/download_nixpkgs-overlay-rust.sh: line 3: curl: command not found
Action failed: root//src/renode:hifive-unleashed-bbl.bin (download_file https://dl.antmicro.com/projects/renode/hifive-unleashed--bbl.elf-s_17219640-c7e1b920bf81be4062f467d9ecf689dbf7f29c7a)
Remote command returned non-zero exit code 127
stdout:
env dump
PWD=/worker/build/db6d3b8b248de7b5/root
SHLVL=1
_=/usr/bin/env
ok
stderr:
buck-out/v2/gen/root/632fe5438d4aecc1/src/renode/__hifive-unleashed-bbl.bin__/download_hifive-unleashed-bbl.bin.sh: line 6: curl: command not found
Action failed: root//src/renode:hifive-unleashed.dtb (download_file https://dl.antmicro.com/projects/renode/hifive-unleashed--devicetree.dtb-s_10532-70cd4fc9f3b4df929eba6e6f22d02e6ce4c17bd1)
Remote command returned non-zero exit code 127
stdout:
env dump
PWD=/worker/build/ab50ec19dbbe693a/root
SHLVL=1
_=/usr/bin/env
ok
stderr:
buck-out/v2/gen/root/632fe5438d4aecc1/src/renode/__hifive-unleashed.dtb__/download_hifive-unleashed.dtb.sh: line 6: curl: command not found
Build ID: 4da18795-4801-4db3-b09d-53e7bc7259e2
RE: GRPC-SESSION-ID
Jobs completed: 103. Time elapsed: 3.5s. Cache hits: 0%. Commands: 4 (cached: 0, remote: 4, local: 0)
BUILD FAILED
Failed to build 'prelude//toolchains:nixpkgs-overlay-rust (prelude//platform:default#632fe5438d4aecc1)'
Failed to build 'root//src/renode:hifive-unleashed-bbl.bin (prelude//platform:default#632fe5438d4aecc1)'
Failed to build 'root//src/renode:hifive-unleashed-vmlinux.bin (prelude//platform:default#632fe5438d4aecc1)'
Failed to build 'root//src/renode:hifive-unleashed.dtb (prelude//platform:default#632fe5438d4aecc1)'

This is because the built container image doesn't have a default PATH that includes curl or anything like it — you can see this in the above output; a patch I added (but didn't commit) uses env to dump the environment and only PWD and SHLVL are defined. We do need to fix this so a minimal environment works for the bash scripts. Then maybe we can get somewhere, but it will probably hit another several bumps.

Use of upstream buck2-prelude

Very cool project :)

I wondered if you'd considered whether it would be possible to reuse the open source upstream Buck2 prelude as well? It seems that Nix is a great source for toolchain definitions, but reimplementing things like Rust/Haskell/OCaml/C++ etc on top separately from the upstream prelude would be a lot of work.

Happy to chat further over video conference or similar if that's easier, and happy to answer any questions you have about Buck2. It's still early days, but integration with Nix is super cool.

Automate buck2 updates

We should just update the buck2 build every day at 00:00 UTC. There is a script that can do this automatically:

./buck/nix/update.sh --buck2

There should be an automated PR against the repo that gets closed automatically once all the tests pass. Once #9 is fixed then the cache will get updated automatically, too. Not sure how to set this up, but if anyone lurking would like to do it aside from me, it would be very useful!

Note: rust-overlay in the flake may also need to be updated along with this as well, in case the rust nightly version changes...

Question: How is nix exactly used?

This MWE looks interesting. When I looked over the file it was unclear to me how it uses Nix. I had the following questions:

  • Is Nix used here as a dependency manager, enabling a package to build over buck?
  • I saw that a written build.nix is used. Is it right that you somehow use a destinct storage for Nix, I saw some „import <…>“syntax? Is this trying to encapsulate nix packages from another? How does this work?
  • Is it right that you integrated nix directly in the buck starlak files differently to the approach „use nix to setup the enviornment with all build tools available, then use buck to build the project“. You are doing something different here I guess maybe using Nix in a even more interessting way? You are also building the projects components as package?

Thanks for the clarifications. I am just wondering what your urge was to combine Nix and Buck as you did, it sounds great 😊, Nix is great but not really a monorepo build tool, so thats probably why?

improving automated setup

here are some notes from installing, i have gotten as far as nix run completing and then running cd, but then i dont have systemd in wsl. if i throw this in a vm or container or something it probably would do systemd right and get to working on ubuntu?

final script essentially:

cd ~
sudo mkdir /nix
CURRENT_USER="$USER"
sudo chown -R "$CURRENT_USER:$CURRENT_USER" /nix
sudo chmod 755 /nix
sudo mkdir -p /etc/nix
sudo touch /etc/nix/nix.conf
sudo chown -R "$CURRENT_USER:$CURRENT_USER" /etc/nix
sudo chmod 755 /etc/nix
sudo chmod 644 /etc/nix/nix.conf
echo 'sandbox = false' | tee -a /etc/nix/nix.conf
echo 'use-sqlite-wal = false' | tee -a /etc/nix/nix.conf
echo "trusted-users = $CURRENT_USER" | tee -a /etc/nix/nix.conf
echo 'experimental-features = flakes nix-command ca-derivations' | sudo tee -a /etc/nix/nix.conf
sh <(curl -L https://nixos.org/nix/install) --no-daemon
source "$HOME/.nix-profile/etc/profile.d/nix.sh"
nix-env -i direnv
echo "eval \"\$(direnv hook bash)\"" >> ~/.profile
eval "$(direnv hook bash)"
# manual user input: [ y, {enter}*3, y*2, isWSL ? n : y ]
nix run \
    --tarball-ttl 0 \
    --accept-flake-config \
    'github:thoughtpolice/buck2-nix?dir=buck/nix#setup'
cd ./buck2-nix.sl

full script notes of first tries

#!/bin/bash

# Host: Windows 10 Enterprise (Developer mode enabled)
# WSL: Ubuntu 20.04 LTS
# Date: 2023-04-18
# Both WSL and Windows are relatively up-to-date, dirty, development environments with a bunch of working build tools.
# I'm not sure if this is a good idea, but I'm going to try to install nix on top of this.
# Also reran with fresh ubuntu wsl install.
cd ~ || return
pwd

# the chown/chmod stuff probably could just stay root, idk how nix works
sudo mkdir /nix
CURRENT_USER="$(whoami)"
sudo chown -R "$CURRENT_USER:$CURRENT_USER" /nix
sudo chmod 755 /nix

sudo mkdir -p /etc/nix
sudo touch /etc/nix/nix.conf
sudo chown -R "$CURRENT_USER:$CURRENT_USER" /etc/nix
sudo chmod 755 /etc/nix
sudo chmod 644 /etc/nix/nix.conf
# based on this for ubuntu wsl: https://ariya.io/2020/05/nix-package-manager-on-ubuntu-or-debian
# probably would be nice to have a nixos config for this idk how that works though
# i wonder do you make docker containers using nix? is that a thing?
# nix.conf can also be in ~/.config/nix/nix.conf ? don't know that trusted-users works for that
echo 'sandbox = false' | tee -a /etc/nix/nix.conf
echo 'use-sqlite-wal = false' | tee -a /etc/nix/nix.conf
echo "trusted-users = $CURRENT_USER" | tee -a /etc/nix/nix.conf
# flakes nix-command needed for `nix run`
# ca-derivations needed for `cd buck2-nix.sl`
echo 'experimental-features = flakes nix-command ca-derivations' | sudo tee -a /etc/nix/nix.conf

sh <(curl -L https://nixos.org/nix/install) --no-daemon

. /home/user/.nix-profile/etc/profile.d/nix.sh

# Error:
#    0: direnv not installed
# Location:
#    src/main.rs:260
#   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ SPANTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
#    0: setup::check_direnv
#       at src/main.rs:243
# // XXX FIXME (aseipp): implement direnv installation
# nix-env -i direnv
# sudo rm -f "/home/linuxbrew/.linuxbrew/bin/direnv"
# sudo rm -f "/home/$CURRENT_USER/.nix-profile/bin/direnv"
# sudo apt install -y direnv
# eval "$(direnv hook bash)"
# source ~/.profile
# based on this, nix should be able to do this install: https://gist.github.com/FruitieX/28500ee32e00a5687c7f5031fb5b9922
# nix-env -iA direnv
# echo "eval \"\$(direnv hook bash)\"" >> ~/.profile
# source ~/.profile

# ultimately i installed and uninstalled multiple times
# i tried exiting and re-entering the shell
# eventually, after a full clean and deleting any which direnv -- sudo apt worked.
# sudo apt install -y direnv

# while apt install works, upon cd into buck2-nix.sl,
# errors on a version check,
# direnv from ubuntu is 2.21.2, req 2.21.3
# so i installed direnv from source, but this is also 2.21.2
# it seems to behave differently, but i'm not sure why
# success like:
# user@PF3EHGYL:~$ cd buck2-nix.sl/
# direnv: loading ~/buck2-nix.sl/.envrc
# direnv: using flake ./buck/nix --accept-flake-config
# evaluating derivation 'path:/home/user/buck2-nix.sl/buck/nix#devShells.x86_64-linux.default'direnv: ([/home/linuxbrew/.linuxbrew/bin/direnv export bash]) is taking a while to execute. Use CTRL-C to give up.
# appears to redownload similar to first install run, may be because of direnv uninstall/install cycles
# curl -sfL https://direnv.net/install.sh | bash

nix-env -i hello
which hello
hello

# maybe this will work, or else exit and re-enter idk
echo "eval \"\$(direnv hook bash)\"" >> ~/.profile
eval "$(direnv hook bash)"

# ~2.9+0.6 GiB
# used defaults when prompted: sapling, current directory, buck2-nix.sl, etc, {enter 3}{y 2}
nix run \
    --tarball-ttl 0 \
    --accept-flake-config \
    'github:thoughtpolice/buck2-nix?dir=buck/nix#setup'

if [ -d buck2-nix.sl ]; then
  # ~2.9+0.6 GiB again?
  cd ./buck2-nix.sl || return
  # around here i had issues with ca-derivations and trusted-user, fixed with sys conf changes

  # had an issue with query cache -- DISK FULL OOPS
  # [1/361/368 built, 1028 copied (2888.4/2892.3 MiB), 600.7 MiB DL] building buck2-unstable-2023-04-17 (buildPhase): error: unable to delete old query cache at `/tmp/nix-build-buck2-unstable-2023-04-17.drv-0/source/target/x86_64-unknown-linux-gnu/release/incrementa
  # [1/361/368 built, 1028 copied (2888.4/2892.3 MiB), 600.7 MiB DL] building buck2-unstable-2023-04-17 (buildPhase): error: could not compile `buck2_action_impl` due to previous error
  # on ctrl+c at this point
  # error (ignored): error: cannot unlink '/tmp/nix-build-buck2-unstable-2023-04-17.drv-0/.cargo/config': Read-only file system
  # error (ignored): error: writing to file: Read-only file system
  # error: interrupted by the user
  # direnv: error signal: killed
  # user@PF3EHGYL:~/buck2-nix.sl$ cd ..
  # direnv: unloading
  # user@PF3EHGYL:~$ cd buck2-nix.sl/
  # direnv: loading ~/buck2-nix.sl/.envrc
  # error: could not set permissions on '/nix/var/nix/profiles/per-user' to 755: Read-only file system
  # error: could not set permissions on '/nix/var/nix/profiles/per-user' to 755: Read-only file system
  # direnv: using flake ./buck/nix --accept-flake-config
  # direnv: nix-direnv: nix version is older than the required 2.4.
  # direnv: error exit status 1
  # user@PF3EHGYL:~/buck2-nix.sl$ nix --version
  # nix (Nix) 2.15.0
  # user@PF3EHGYL:~/buck2-nix.sl$ nix-direnv --version
  # nix-direnv: command not found
  # disk was full! deleting files trying again.
  # this caused major issues for my ubuntu wsl,
  # wsl --terminate ubuntu
  # even after this `ubuntu` wouldn't connect.
  # wsl --unregister ubuntu
  # wsl --install -d ubuntu
  # wsl --set-version ubuntu 2
  # ^^ probably default, but just in case
  # ln: failed to create symbolic link '/nix/var/nix/gcroots/per-user/user/home-user-buck2--nix.sl-.direnv-flake--inputs--24vhlhl99pvzg32d50yvyqrw69w9c0r8--source': No such file or directory
  # direnv: nix-direnv: renewed cache
  # direnv: watchman: ERROR: cannot enable, because you aren't using systemd
  # direnv: error exit status 1

    pwd
fi

Get execution platforms and aarch64-linux supported properly

I think I have an OK understanding of how execution platforms, etc should work. But not all the targets work on my laptop, particularly renode ones, so we need to conditionalize them with select(). Also, buildbarn probably doesn't work either... We'll have to figure this out.

submodules

it may be helpful to have submodules

nix-prelude -- current contents of buck/prelude
nix-buck2 -- current contents of buck/nix
nix-dotfiles -- uh.. all the dotfiles in root

and then, ideal state, a script you can curl which would inject these submodules, symlink the dotfiles, maybe rest of automated setup with nix/direnv whatever that is in setup.sh today.

so that these can be imported into others repos as submodules, like the buck2-prelude

i uh... am very beginner at nix, so i dont know that i really want to customize much of anything?

i think i could run the nix run command and then go use that as my starter template, but if i already have a repo, or but also i dont want to maintain fork and merge in upstream changes so that i can have my own src folder.

but i also want any awesome updates you make. ;-)

for now i just like, copied major portions and am winging it (badly), and am planning checking the diff occasionally, but generally i dont know others would want that, they may prefer to just occasionally pull updates for their submodule. i could have also just submoduled this repo just somewhere and then symlinked directories needed out of it, but w/e. pretend i did that.


i suppose if buck/nix is a submodule then nix run <...> github: might break? it would work fine if you clone it of course, but maybe that would be a ux issue if downstream consumers want to provide a nix run command to their users, like in this repo readme.

Can we use a newer shell?

The rules written from scratch here don't have to use bash, and alternative shells such as nushell are a possibility. The questions are:

  • Can we use this shell for scripting in rules?
    • The workflow is something like "Write a script file then run nushell on it to do something arbitrary" via ctx.actions.run
    • The mother of all these things is genrule()
    • It would always be good to not use Bash for anything important.
  • Can we use it for the development environment in a turnkey, reasonable way?
    • That is, the user should get dropped into a pre-configured shell, just like today
    • We could utilize this to have a much more uniform experience.
    • This is where a better language will really shine, since we can equip the environment with more tools and utilies.

Currently, I have used Oil as a replacement for Bash in this repository, with the hope that we would be able to use the Oil language. But inevitably some other platform compatibility may occur for some subset of the rules, and having a single shell language would be great. There's no reason to tie ourselves to something trying to be compatible and besides, the C++ implementation of Oil is a ways off yet.

Powershell is also another possibility, actually. But I think those are the two (or three) main possible contenders.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.